woocommerce/packages/woocommerce-blocks/build/cart-blocks/line-items-frontend.js
2021-12-10 12:03:04 +00:00

13 lines
18 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[27],{106:function(e,t,c){"use strict";var a=c(6),r=c.n(a);c(184),t.a=function(e){var t=e.children,c=e.className;return React.createElement("div",{className:r()("wc-block-components-product-badge",c)},t)}},140:function(e,t,c){"use strict";var a=c(4),r=c.n(a),n=c(1),i=c(69),o=c(6),l=c.n(o),u=(c(10),c(58)),s=c(0),m=(c(183),function(e){var t=e.currency,c=e.maxPrice,a=e.minPrice,r=e.priceClassName,o=e.priceStyle;return React.createElement(React.Fragment,null,React.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(u.formatPrice)(a),Object(u.formatPrice)(c))),React.createElement("span",{"aria-hidden":!0},React.createElement(i.a,{className:l()("wc-block-components-product-price__value",r),currency:t,value:a,style:o})," — ",React.createElement(i.a,{className:l()("wc-block-components-product-price__value",r),currency:t,value:c,style:o})))}),p=function(e){var t=e.currency,c=e.regularPriceClassName,a=e.regularPriceStyle,r=e.regularPrice,o=e.priceClassName,u=e.priceStyle,s=e.price;return React.createElement(React.Fragment,null,React.createElement("span",{className:"screen-reader-text"},Object(n.__)("Previous price:",'woocommerce')),React.createElement(i.a,{currency:t,renderText:function(e){return React.createElement("del",{className:l()("wc-block-components-product-price__regular",c),style:a},e)},value:r}),React.createElement("span",{className:"screen-reader-text"},Object(n.__)("Discounted price:",'woocommerce')),React.createElement(i.a,{currency:t,renderText:function(e){return React.createElement("ins",{className:l()("wc-block-components-product-price__value","is-discounted",o),style:u},e)},value:s}))};t.a=function(e){var t=e.align,c=e.className,a=e.currency,n=e.format,o=void 0===n?"<price/>":n,u=e.maxPrice,d=void 0===u?null:u,b=e.minPrice,v=void 0===b?null:b,f=e.price,_=void 0===f?null:f,y=e.priceClassName,g=e.priceStyle,k=e.regularPrice,O=e.regularPriceClassName,E=e.regularPriceStyle,w=l()(c,"price","wc-block-components-product-price",r()({},"wc-block-components-product-price--align-".concat(t),t));o.includes("<price/>")||(o="<price/>",console.error("Price formats need to include the `<price/>` tag."));var R=k&&_!==k,j=React.createElement("span",{className:l()("wc-block-components-product-price__value",y)});return R?j=React.createElement(p,{currency:a,price:_,priceClassName:y,priceStyle:g,regularPrice:k,regularPriceClassName:O,regularPriceStyle:E}):null!==v&&null!==d?j=React.createElement(m,{currency:a,maxPrice:d,minPrice:v,priceClassName:y,priceStyle:g}):null!==_&&(j=React.createElement(i.a,{className:l()("wc-block-components-product-price__value",y),currency:a,value:_,style:g})),React.createElement("span",{className:w},Object(s.createInterpolateElement)(o,{price:j}))}},147:function(e,t){},150:function(e,t,c){"use strict";var a=c(14),r=c.n(a),n=c(23),i=c.n(n),o=c(28),l=c(6),u=c.n(l),s=(c(182),["className","disabled","name","permalink"]);t.a=function(e){var t=e.className,c=void 0===t?"":t,a=e.disabled,n=void 0!==a&&a,l=e.name,m=e.permalink,p=void 0===m?"":m,d=i()(e,s),b=u()("wc-block-components-product-name",c);return n?React.createElement("span",r()({className:b},d,{dangerouslySetInnerHTML:{__html:Object(o.decodeEntities)(l)}})):React.createElement("a",r()({className:b,href:p},d,{dangerouslySetInnerHTML:{__html:Object(o.decodeEntities)(l)}}))}},151:function(e,t,c){"use strict";var a=c(0),r=c(113),n=c(97),i=function(e){var t=e.indexOf("</p>");return-1===t?e:e.substr(0,t+4)},o=function(e){return e.replace(/<\/?[a-z][^>]*?>/gi,"")},l=function(e,t){return e.replace(/[\s|\.\,]+$/i,"")+t},u=function(e,t){var c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"&hellip;",a=o(e),r=a.split(" ").splice(0,t).join(" ");return Object(n.autop)(l(r,c))},s=function(e,t){var c=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"&hellip;",r=o(e),i=r.slice(0,t);if(c)return Object(n.autop)(l(i,a));var u=i.match(/([\s]+)/g),s=u?u.length:0,m=r.slice(0,t+s);return Object(n.autop)(l(m,a))};t.a=function(e){var t=e.source,c=e.maxLength,o=void 0===c?15:c,l=e.countType,m=void 0===l?"words":l,p=e.className,d=void 0===p?"":p,b=Object(a.useMemo)((function(){return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"words",a=Object(n.autop)(e),o=Object(r.count)(a,c);if(o<=t)return a;var l=i(a),m=Object(r.count)(l,c);return m<=t?l:"words"===c?u(l,t):s(l,t,"characters_including_spaces"===c)}(t,o,m)}),[t,o,m]);return React.createElement(a.RawHTML,{className:d},b)}},155:function(e,t,c){"use strict";var a=c(21),r=c.n(a),n=c(1),i=c(33),o=c(6),l=c.n(o),u=c(0),s=c(50),m=c(49);c(190),t.a=function(e){var t=e.className,c=e.quantity,a=void 0===c?1:c,o=e.minimum,p=void 0===o?1:o,d=e.maximum,b=e.onChange,v=void 0===b?function(){}:b,f=e.itemName,_=void 0===f?"":f,y=e.disabled,g=l()("wc-block-components-quantity-selector",t),k=void 0!==d,O=a>p,E=!k||a<d,w=Object(u.useCallback)((function(e){var t=void 0!==r()(e.key)?"ArrowDown"===e.key:e.keyCode===s.DOWN,c=void 0!==r()(e.key)?"ArrowUp"===e.key:e.keyCode===s.UP;t&&O&&(e.preventDefault(),v(a-1)),c&&E&&(e.preventDefault(),v(a+1))}),[a,v,E,O]);return React.createElement("div",{className:g},React.createElement("input",{className:"wc-block-components-quantity-selector__input",disabled:y,type:"number",step:"1",min:"0",value:a,onKeyDown:w,onChange:function(e){var t=Object(m.a)(e.target.value)&&e.target.value?parseInt(e.target.value,10):0;k&&(t=Math.min(t,d)),(t=Math.max(t,p))!==a&&v(t)},"aria-label":Object(n.sprintf)(
/* translators: %s refers to the item name in the cart. */
Object(n.__)("Quantity of %s in your cart.",'woocommerce'),_)}),React.createElement("button",{"aria-label":Object(n.__)("Reduce quantity",'woocommerce'),className:"wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--minus",disabled:y||!O,onClick:function(){var e=a-1;v(e),Object(i.speak)(Object(n.sprintf)(
/* translators: %s refers to the item name in the cart. */
Object(n.__)("Quantity reduced to %s.",'woocommerce'),e))}},""),React.createElement("button",{"aria-label":Object(n.__)("Increase quantity",'woocommerce'),disabled:y||!E,className:"wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--plus",onClick:function(){var e=a+1;v(e),Object(i.speak)(Object(n.sprintf)(
/* translators: %s refers to the item name in the cart. */
Object(n.__)("Quantity increased to %s.",'woocommerce'),e))}},""))}},182:function(e,t){},183:function(e,t){},184:function(e,t){},185:function(e,t){},186:function(e,t){},190:function(e,t){},266:function(e,t,c){"use strict";var a=c(14),r=c.n(a),n=c(28),i=c(2);t.a=function(e){var t=e.image,c=void 0===t?{}:t,a={src:c.thumbnail||i.PLACEHOLDER_IMG_SRC,alt:Object(n.decodeEntities)(c.alt)||""};return React.createElement("img",r()({},a,{alt:a.alt}))}},267:function(e,t,c){"use strict";var a=c(1),r=c(106);t.a=function(){return React.createElement(r.a,{className:"wc-block-components-product-backorder-badge"},Object(a.__)("Available on backorder",'woocommerce'))}},268:function(e,t,c){"use strict";var a=c(1),r=c(106);t.a=function(e){var t=e.lowStockRemaining;return t?React.createElement(r.a,{className:"wc-block-components-product-low-stock-badge"},Object(a.sprintf)(
/* translators: %d stock amount (number of items in stock for product) */
Object(a.__)("%d left in stock",'woocommerce'),t)):null}},269:function(e,t,c){"use strict";var a=c(7),r=c(28),n=(c(186),function(e){var t=e.details,c=void 0===t?[]:t;return Array.isArray(c)?0===(c=c.filter((function(e){return!e.hidden}))).length?null:React.createElement("ul",{className:"wc-block-components-product-details"},c.map((function(e){var t=e.name?"wc-block-components-product-details__".concat(Object(a.kebabCase)(e.name)):"";return React.createElement("li",{key:e.name+(e.display||e.value),className:t},e.name&&React.createElement(React.Fragment,null,React.createElement("span",{className:"wc-block-components-product-details__name"},Object(r.decodeEntities)(e.name),":")," "),React.createElement("span",{className:"wc-block-components-product-details__value"},Object(r.decodeEntities)(e.display||e.value)))}))):null}),i=c(151),o=c(83),l=function(e){var t=e.className,c=e.shortDescription,a=void 0===c?"":c,r=e.fullDescription,n=a||(void 0===r?"":r);return n?React.createElement(i.a,{className:t,source:n,maxLength:15,countType:o.n.wordCountType||"words"}):null};c(185),t.a=function(e){var t=e.shortDescription,c=void 0===t?"":t,a=e.fullDescription,r=void 0===a?"":a,i=e.itemData,o=void 0===i?[]:i,u=e.variation,s=void 0===u?[]:u;return React.createElement("div",{className:"wc-block-components-product-metadata"},React.createElement(l,{className:"wc-block-components-product-metadata__description",shortDescription:c,fullDescription:r}),React.createElement(n,{details:o}),React.createElement(n,{details:s.map((function(e){var t=e.attribute;return{name:void 0===t?"":t,value:e.value}}))}))}},278:function(e,t,c){"use strict";c.d(t,"a",(function(){return b}));var a=c(5),r=c.n(a),n=c(11),i=c(0),o=c(8),l=c(115),u=c(99),s=c(137),m=c(49),p=c(32),d=c(48),b=function(e){var t={key:"",quantity:1};(function(e){return Object(m.b)(e)&&Object(m.d)(e,"key")&&Object(m.d)(e,"quantity")&&Object(m.c)(e.key)&&Object(m.a)(e.quantity)})(e)&&(t.key=e.key,t.quantity=e.quantity);var c=t.key,a=void 0===c?"":c,b=t.quantity,v=void 0===b?1:b,f=Object(p.a)().cartErrors,_=Object(d.b)().dispatchActions,y=Object(i.useState)(v),g=r()(y,2),k=g[0],O=g[1],E=Object(l.a)(k,400),w=r()(E,1)[0],R=Object(u.a)(w),j=Object(n.useDispatch)(o.CART_STORE_KEY),N=j.removeItemFromCart,h=j.changeCartItemQuantity,C=Object(n.useSelect)((function(e){if(!a)return{quantity:!1,delete:!1};var t=e(o.CART_STORE_KEY);return{quantity:t.isItemPendingQuantity(a),delete:t.isItemPendingDelete(a)}}),[a]),P=Object(i.useCallback)((function(){return a?N(a).then((function(){return Object(s.c)(),!0})):Promise.resolve(!1)}),[a,N]);return Object(i.useEffect)((function(){a&&Object(m.a)(R)&&Number.isFinite(R)&&R!==w&&h(a,w)}),[a,h,w,R]),Object(i.useEffect)((function(){return C.delete?_.incrementCalculating():_.decrementCalculating(),function(){C.delete&&_.decrementCalculating()}}),[_,C.delete]),Object(i.useEffect)((function(){return C.quantity||w!==k?_.incrementCalculating():_.decrementCalculating(),function(){(C.quantity||w!==k)&&_.decrementCalculating()}}),[_,C.quantity,w,k]),{isPendingDelete:C.delete,quantity:k,setItemQuantity:O,removeItem:P,cartItemQuantityErrors:f}}},279:function(e,t,c){"use strict";var a=c(0),r=c(1),n=c(69),i=c(106);t.a=function(e){var t=e.currency,c=e.saleAmount,o=e.format,l=void 0===o?"<price/>":o;if(!c||c<=0)return null;l.includes("<price/>")||(l="<price/>",console.error("Price formats need to include the `<price/>` tag."));var u=Object(r.sprintf)(
/* translators: %s will be replaced by the discount amount */
Object(r.__)("Save %s",'woocommerce'),l);return React.createElement(i.a,{className:"wc-block-components-sale-badge"},Object(a.createInterpolateElement)(u,{price:React.createElement(n.a,{currency:t,value:c})}))}},414:function(e,t,c){"use strict";c.r(t);var a=c(32),r=c(46),n=c.n(r),i=c(1),o=c(23),l=c.n(o),u=c(6),s=c.n(u),m=c(155),p=c(140),d=c(150),b=c(278),v=c(52),f=c(266),_=c(267),y=c(268),g=c(279),k=c(269),O=c(58),E=c(26),w=c(125),R=c(0),j=c(49),N=c(2),h=["receiveCart"],C=function(e,t){return e.convertPrecision(t.minorUnit).getAmount()},P=function(e){return Object(E.mustContain)(e,"<price/>")},x=function(e){var t=e.lineItem,c=t.name,r=void 0===c?"":c,n=t.catalog_visibility,o=void 0===n?"visible":n,u=t.short_description,x=void 0===u?"":u,I=t.description,S=void 0===I?"":I,D=t.low_stock_remaining,q=void 0===D?null:D,A=t.show_backorder_badge,T=void 0!==A&&A,F=t.quantity_limit,L=void 0===F?99:F,M=t.permalink,U=void 0===M?"":M,Q=t.images,V=void 0===Q?[]:Q,$=t.variation,H=void 0===$?[]:$,B=t.item_data,K=void 0===B?[]:B,W=t.prices,J=void 0===W?{currency_code:"USD",currency_minor_unit:2,currency_symbol:"$",currency_prefix:"$",currency_suffix:"",currency_decimal_separator:".",currency_thousand_separator:",",price:"0",regular_price:"0",sale_price:"0",price_range:null,raw_prices:{precision:6,price:"0",regular_price:"0",sale_price:"0"}}:W,Y=t.totals,z=void 0===Y?{currency_code:"USD",currency_minor_unit:2,currency_symbol:"$",currency_prefix:"$",currency_suffix:"",currency_decimal_separator:".",currency_thousand_separator:",",line_subtotal:"0",line_subtotal_tax:"0"}:Y,G=t.extensions,X=Object(b.a)(t),Z=X.quantity,ee=X.setItemQuantity,te=X.removeItem,ce=X.isPendingDelete,ae=Object(v.a)().dispatchStoreEvent,re=Object(a.a)(),ne=(re.receiveCart,l()(re,h)),ie=Object(R.useMemo)((function(){return{context:"cart",cartItem:t,cart:ne}}),[t,ne]),oe=Object(O.getCurrencyFromPriceResponse)(J),le=Object(E.__experimentalApplyCheckoutFilter)({filterName:"itemName",defaultValue:r,extensions:G,arg:ie}),ue=Object(w.a)({amount:parseInt(J.raw_prices.regular_price,10),precision:J.raw_prices.precision}),se=Object(w.a)({amount:parseInt(J.raw_prices.price,10),precision:J.raw_prices.precision}),me=ue.subtract(se),pe=me.multiply(Z),de=Object(O.getCurrencyFromPriceResponse)(z),be=parseInt(z.line_subtotal,10);Object(N.getSetting)("displayCartPricesIncludingTax",!1)&&(be+=parseInt(z.line_subtotal_tax,10));var ve=Object(w.a)({amount:be,precision:de.minorUnit}),fe=V.length?V[0]:{},_e="hidden"===o||"search"===o,ye=Object(E.__experimentalApplyCheckoutFilter)({filterName:"cartItemPrice",defaultValue:"<price/>",extensions:G,arg:ie,validation:P}),ge=Object(E.__experimentalApplyCheckoutFilter)({filterName:"subtotalPriceFormat",defaultValue:"<price/>",extensions:G,arg:ie,validation:P}),ke=Object(E.__experimentalApplyCheckoutFilter)({filterName:"saleBadgePriceFormat",defaultValue:"<price/>",extensions:G,arg:ie,validation:P});return React.createElement("tr",{className:s()("wc-block-cart-items__row",{"is-disabled":ce})},React.createElement("td",{className:"wc-block-cart-item__image","aria-hidden":!Object(j.d)(fe,"alt")||!fe.alt},_e?React.createElement(f.a,{image:fe}):React.createElement("a",{href:U,tabIndex:-1},React.createElement(f.a,{image:fe}))),React.createElement("td",{className:"wc-block-cart-item__product"},React.createElement(d.a,{disabled:ce||_e,name:le,permalink:U}),T?React.createElement(_.a,null):!!q&&React.createElement(y.a,{lowStockRemaining:q}),React.createElement("div",{className:"wc-block-cart-item__prices"},React.createElement(p.a,{currency:oe,regularPrice:C(ue,oe),price:C(se,oe),format:ge})),React.createElement(g.a,{currency:oe,saleAmount:C(me,oe),format:ke}),React.createElement(k.a,{shortDescription:x,fullDescription:S,itemData:K,variation:H}),React.createElement("div",{className:"wc-block-cart-item__quantity"},React.createElement(m.a,{disabled:ce,quantity:Z,maximum:L,onChange:function(e){ee(e),ae("cart-set-item-quantity",{product:t,quantity:e})},itemName:le}),React.createElement("button",{className:"wc-block-cart-item__remove-link",onClick:function(){te(),ae("cart-remove-item",{product:t,quantity:Z})},disabled:ce},Object(i.__)("Remove item",'woocommerce')))),React.createElement("td",{className:"wc-block-cart-item__total"},React.createElement("div",{className:"wc-block-cart-item__total-price-and-sale-badge-wrapper"},React.createElement(p.a,{currency:de,format:ye,price:ve.getAmount()}),Z>1&&React.createElement(g.a,{currency:oe,saleAmount:C(pe,oe),format:ke}))))},I=n()(Array(3)).map((function(_x,e){return React.createElement(x,{lineItem:{},key:e})})),S=function(e){var t=e.lineItems,c=void 0===t?[]:t,a=e.isLoading,r=void 0!==a&&a?I:c.map((function(e){return React.createElement(x,{key:e.key,lineItem:e})}));return React.createElement("table",{className:"wc-block-cart-items"},React.createElement("thead",null,React.createElement("tr",{className:"wc-block-cart-items__header"},React.createElement("th",{className:"wc-block-cart-items__header-image"},React.createElement("span",null,Object(i.__)("Product",'woocommerce'))),React.createElement("th",{className:"wc-block-cart-items__header-product"},React.createElement("span",null,Object(i.__)("Details",'woocommerce'))),React.createElement("th",{className:"wc-block-cart-items__header-total"},React.createElement("span",null,Object(i.__)("Total",'woocommerce'))))),React.createElement("tbody",null,r))};t.default=function(){var e=Object(a.a)(),t=e.cartItems,c=e.cartIsLoading;return React.createElement(S,{lineItems:t,isLoading:c})}},69:function(e,t,c){"use strict";var a=c(14),r=c.n(a),n=c(4),i=c.n(n),o=c(23),l=c.n(o),u=c(126),s=c(6),m=c.n(s),p=(c(147),["className","value","currency","onValueChange","displayType"]);function d(e,t){var c=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),c.push.apply(c,a)}return c}function b(e){for(var t=1;t<arguments.length;t++){var c=null!=arguments[t]?arguments[t]:{};t%2?d(Object(c),!0).forEach((function(t){i()(e,t,c[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(c)):d(Object(c)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(c,t))}))}return e}t.a=function(e){var t=e.className,c=e.value,a=e.currency,n=e.onValueChange,i=e.displayType,o=void 0===i?"text":i,s=l()(e,p),d="string"==typeof c?parseInt(c,10):c;if(!Number.isFinite(d))return null;var v=d/Math.pow(10,a.minorUnit);if(!Number.isFinite(v))return null;var f=m()("wc-block-formatted-money-amount","wc-block-components-formatted-money-amount",t),_=b(b(b({},s),function(e){return{thousandSeparator:e.thousandSeparator,decimalSeparator:e.decimalSeparator,decimalScale:e.minorUnit,fixedDecimalScale:!0,prefix:e.prefix,suffix:e.suffix,isNumericString:!0}}(a)),{},{value:void 0,currency:void 0,onValueChange:void 0}),y=n?function(e){var t=e.value*Math.pow(10,a.minorUnit);n(t)}:function(){};return React.createElement(u.a,r()({className:f,displayType:o},_,{value:v,onValueChange:y}))}}}]);