11 lines
16 KiB
JavaScript
11 lines
16 KiB
JavaScript
(self.webpackChunkwebpackWcBlocksFrontendJsonp=self.webpackChunkwebpackWcBlocksFrontendJsonp||[]).push([[514],{7121:(e,t,r)=>{"use strict";r.d(t,{Z:()=>o});var a=r(9196),c=r(2629),n=r(7608),l=r.n(n);r(333);const o=({className:e="",disabled:t=!1,name:r,permalink:n="",target:o,rel:s,style:i,onClick:m,...u})=>{const p=l()("wc-block-components-product-name",e);if(t){const e=u;return(0,a.createElement)("span",{className:p,...e,dangerouslySetInnerHTML:{__html:(0,c.decodeEntities)(r)}})}return(0,a.createElement)("a",{className:p,href:n,target:o,...u,dangerouslySetInnerHTML:{__html:(0,c.decodeEntities)(r)},style:i})}},3088:(e,t,r)=>{"use strict";r.d(t,{Z:()=>p});var a=r(9196),c=r(5736),n=r(711),l=r(7608),o=r.n(l),s=r(4293),i=r(9307);r(5437);const m=({currency:e,maxPrice:t,minPrice:r,priceClassName:l,priceStyle:i={}})=>(0,a.createElement)(a.Fragment,null,(0,a.createElement)("span",{className:"screen-reader-text"},(0,c.sprintf)(/* translators: %1$s min price, %2$s max price */ /* translators: %1$s min price, %2$s max price */
|
||
(0,c.__)("Price between %1$s and %2$s","woocommerce"),(0,s.formatPrice)(r),(0,s.formatPrice)(t))),(0,a.createElement)("span",{"aria-hidden":!0},(0,a.createElement)(n.FormattedMonetaryAmount,{className:o()("wc-block-components-product-price__value",l),currency:e,value:r,style:i})," — ",(0,a.createElement)(n.FormattedMonetaryAmount,{className:o()("wc-block-components-product-price__value",l),currency:e,value:t,style:i}))),u=({currency:e,regularPriceClassName:t,regularPriceStyle:r,regularPrice:l,priceClassName:s,priceStyle:i,price:m})=>(0,a.createElement)(a.Fragment,null,(0,a.createElement)("span",{className:"screen-reader-text"},(0,c.__)("Previous price:","woocommerce")),(0,a.createElement)(n.FormattedMonetaryAmount,{currency:e,renderText:e=>(0,a.createElement)("del",{className:o()("wc-block-components-product-price__regular",t),style:r},e),value:l}),(0,a.createElement)("span",{className:"screen-reader-text"},(0,c.__)("Discounted price:","woocommerce")),(0,a.createElement)(n.FormattedMonetaryAmount,{currency:e,renderText:e=>(0,a.createElement)("ins",{className:o()("wc-block-components-product-price__value","is-discounted",s),style:i},e),value:m})),p=({align:e,className:t,currency:r,format:c="<price/>",maxPrice:l,minPrice:s,price:p,priceClassName:d,priceStyle:_,regularPrice:y,regularPriceClassName:b,regularPriceStyle:E,style:f})=>{const k=o()(t,"price","wc-block-components-product-price",{[`wc-block-components-product-price--align-${e}`]:e});c.includes("<price/>")||(c="<price/>",console.error("Price formats need to include the `<price/>` tag."));const w=y&&p&&p<y;let g=(0,a.createElement)("span",{className:o()("wc-block-components-product-price__value",d)});return w?g=(0,a.createElement)(u,{currency:r,price:p,priceClassName:d,priceStyle:_,regularPrice:y,regularPriceClassName:b,regularPriceStyle:E}):void 0!==s&&void 0!==l?g=(0,a.createElement)(m,{currency:r,maxPrice:l,minPrice:s,priceClassName:d,priceStyle:_}):p&&(g=(0,a.createElement)(n.FormattedMonetaryAmount,{className:o()("wc-block-components-product-price__value",d),currency:r,value:p,style:_})),(0,a.createElement)("span",{className:k,style:f},(0,i.createInterpolateElement)(c,{price:g}))}},1459:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>K});var a=r(9196),c=r(9659),n=r(7608),l=r.n(n),o=r(5736),s=r(9307),i=r(5158),m=r(9630),u=r(2600);r(8968);const p=({className:e,quantity:t=1,minimum:r=1,maximum:c,onChange:n=(()=>{}),step:p=1,itemName:d="",disabled:_})=>{const y=l()("wc-block-components-quantity-selector",e),b=(0,s.useRef)(null),E=(0,s.useRef)(null),f=(0,s.useRef)(null),k=void 0!==c,w=!_&&t-p>=r,g=!_&&(!k||t+p<=c),N=(0,s.useCallback)((e=>{let t=e;k&&(t=Math.min(t,Math.floor(c/p)*p)),t=Math.max(t,Math.ceil(r/p)*p),t=Math.floor(t/p)*p,t!==e&&n(t)}),[k,c,r,n,p]),v=(0,u.y1)(N,300);(0,s.useLayoutEffect)((()=>{N(t)}),[t,N]);const h=(0,s.useCallback)((e=>{const r=void 0!==typeof e.key?"ArrowDown"===e.key:e.keyCode===m.DOWN,a=void 0!==typeof e.key?"ArrowUp"===e.key:e.keyCode===m.UP;r&&w&&(e.preventDefault(),n(t-p)),a&&g&&(e.preventDefault(),n(t+p))}),[t,n,g,w,p]);return(0,a.createElement)("div",{className:y},(0,a.createElement)("input",{ref:b,className:"wc-block-components-quantity-selector__input",disabled:_,type:"number",step:p,min:r,max:c,value:t,onKeyDown:h,onChange:e=>{let r=parseInt(e.target.value,10);r=isNaN(r)?t:r,r!==t&&(n(r),v(r))},"aria-label":(0,o.sprintf)(/* translators: %s refers to the item name in the cart. */ /* translators: %s refers to the item name in the cart. */
|
||
(0,o.__)("Quantity of %s in your cart.","woocommerce"),d)}),(0,a.createElement)("button",{ref:E,"aria-label":(0,o.sprintf)(/* translators: %s refers to the item name in the cart. */ /* translators: %s refers to the item name in the cart. */
|
||
(0,o.__)("Reduce quantity of %s","woocommerce"),d),className:"wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--minus",disabled:!w,onClick:()=>{const e=t-p;n(e),(0,i.speak)((0,o.sprintf)(/* translators: %s refers to the item's new quantity in the cart. */ /* translators: %s refers to the item's new quantity in the cart. */
|
||
(0,o.__)("Quantity reduced to %s.","woocommerce"),e)),N(e)}},"-"),(0,a.createElement)("button",{ref:f,"aria-label":(0,o.sprintf)(/* translators: %s refers to the item's name in the cart. */ /* translators: %s refers to the item's name in the cart. */
|
||
(0,o.__)("Increase quantity of %s","woocommerce"),d),disabled:!g,className:"wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--plus",onClick:()=>{const e=t+p;n(e),(0,i.speak)((0,o.sprintf)(/* translators: %s refers to the item's new quantity in the cart. */ /* translators: %s refers to the item's new quantity in the cart. */
|
||
(0,o.__)("Quantity increased to %s.","woocommerce"),e)),N(e)}},"+"))};var d=r(3088),_=r(7121),y=r(9818),b=r(4801),E=r(8161),f=r(6946);var k=r(8360),w=r(4293),g=r(3554),N=r(1064),v=r(4617);r(2930);const h=({children:e,className:t})=>(0,a.createElement)("div",{className:l()("wc-block-components-product-badge",t)},e),C=()=>(0,a.createElement)(h,{className:"wc-block-components-product-backorder-badge"},(0,o.__)("Available on backorder","woocommerce"));var P=r(2629);const I=({image:e={},fallbackAlt:t=""})=>{const r=e.thumbnail?{src:e.thumbnail,alt:(0,P.decodeEntities)(e.alt)||t||"Product Image"}:{src:v.PLACEHOLDER_IMG_SRC,alt:""};return(0,a.createElement)("img",{...r,alt:r.alt})},x=({lowStockRemaining:e})=>e?(0,a.createElement)(h,{className:"wc-block-components-product-low-stock-badge"},(0,o.sprintf)(/* translators: %d stock amount (number of items in stock for product) */ /* translators: %d stock amount (number of items in stock for product) */
|
||
(0,o.__)("%d left in stock","woocommerce"),e)):null;var q=r(7427);r(3804);const D=({details:e=[]})=>Array.isArray(e)?0===(e=e.filter((e=>!e.hidden))).length?null:(0,a.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__${(0,q.o)(t)}`:"");return(0,a.createElement)("li",{key:t+(e.display||e.value),className:r},t&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)("span",{className:"wc-block-components-product-details__name"},(0,P.decodeEntities)(t),":")," "),(0,a.createElement)("span",{className:"wc-block-components-product-details__value"},(0,P.decodeEntities)(e.display||e.value)))}))):null;var R=r(987);const S=e=>e.replace(/<\/?[a-z][^>]*?>/gi,""),A=(e,t)=>e.replace(/[\s|\.\,]+$/i,"")+t;var F=r(5266);const M=({source:e,maxLength:t=15,countType:r="words",className:c="",style:n={}})=>{const l=(0,s.useMemo)((()=>((e,t=15,r="words")=>{const a=(0,R.autop)(e);if((0,F.count)(a,r)<=t)return a;const c=(e=>{const t=e.indexOf("</p>");return-1===t?e:e.substr(0,t+4)})(a);return(0,F.count)(c,r)<=t?c:"words"===r?((e,t,r="…",a=!0)=>{const c=S(e),n=c.split(" ").splice(0,t).join(" ");return n===c?a?(0,R.autop)(c):c:a?(0,R.autop)(A(n,r)):A(n,r)})(c,t):((e,t,r=!0,a="…",c=!0)=>{const n=S(e),l=n.slice(0,t);if(l===n)return c?(0,R.autop)(n):n;if(r)return(0,R.autop)(A(l,a));const o=l.match(/([\s]+)/g),s=o?o.length:0,i=n.slice(0,t+s);return c?(0,R.autop)(A(i,a)):A(i,a)})(c,t,"characters_including_spaces"===r)})(e,t,r)),[e,t,r]);return(0,a.createElement)(s.RawHTML,{style:n,className:c},l)};var T=r(8752);const L=({className:e,shortDescription:t="",fullDescription:r=""})=>{const c=t||r;return c?(0,a.createElement)(M,{className:e,source:c,maxLength:15,countType:T.Cm.wordCountType||"words"}):null};r(6021);const H=({shortDescription:e="",fullDescription:t="",itemData:r=[],variation:c=[]})=>(0,a.createElement)("div",{className:"wc-block-components-product-metadata"},(0,a.createElement)(L,{className:"wc-block-components-product-metadata__description",shortDescription:e,fullDescription:t}),(0,a.createElement)(D,{details:r}),(0,a.createElement)(D,{details:c.map((({attribute:e="",value:t})=>({key:e,value:t})))}));var V=r(711);const $=({currency:e,saleAmount:t,format:r="<price/>"})=>{if(!t||t<=0)return null;r.includes("<price/>")||(r="<price/>",console.error("Price formats need to include the `<price/>` tag."));const c=(0,o.sprintf)(/* translators: %s will be replaced by the discount amount */ /* translators: %s will be replaced by the discount amount */
|
||
(0,o.__)("Save %s","woocommerce"),r);return(0,a.createElement)(h,{className:"wc-block-components-sale-badge"},(0,s.createInterpolateElement)(c,{price:(0,a.createElement)(V.FormattedMonetaryAmount,{currency:e,value:t})}))},O=(e,t)=>e.convertPrecision(t.minorUnit).getAmount(),Q=(0,s.forwardRef)((({lineItem:e,onRemove:t=(()=>{}),tabIndex:r},n)=>{const{name:m="",catalog_visibility:h="visible",short_description:P="",description:q="",low_stock_remaining:D=null,show_backorder_badge:R=!1,quantity_limits:S={minimum:1,maximum:99,multiple_of:1,editable:!0},sold_individually:A=!1,permalink:F="",images:M=[],variation:T=[],item_data:L=[],prices:V={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"}},totals:Q={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"},extensions:Z}=e,{quantity:U,setItemQuantity:j,removeItem:K,isPendingDelete:B}=(e=>{const t={key:"",quantity:1};(e=>(0,f.isObject)(e)&&(0,f.objectHasProp)(e,"key")&&(0,f.objectHasProp)(e,"quantity")&&(0,f.isString)(e.key)&&(0,f.isNumber)(e.quantity))(e)&&(t.key=e.key,t.quantity=e.quantity);const{key:r="",quantity:a=1}=t,{cartErrors:n}=(0,c.b)(),{__internalIncrementCalculating:l,__internalDecrementCalculating:o}=(0,y.useDispatch)(b.CHECKOUT_STORE_KEY),[i,m]=(0,s.useState)(a),[p]=(0,u.Nr)(i,400),d=(0,E.D)(p),{removeItemFromCart:_,changeCartItemQuantity:k}=(0,y.useDispatch)(b.CART_STORE_KEY);(0,s.useEffect)((()=>m(a)),[a]);const w=(0,y.useSelect)((e=>{if(!r)return{quantity:!1,delete:!1};const t=e(b.CART_STORE_KEY);return{quantity:t.isItemPendingQuantity(r),delete:t.isItemPendingDelete(r)}}),[r]),g=(0,s.useCallback)((()=>r?_(r).catch((e=>{(0,b.processErrorResponse)(e)})):Promise.resolve(!1)),[r,_]);return(0,s.useEffect)((()=>{r&&(0,f.isNumber)(d)&&Number.isFinite(d)&&d!==p&&k(r,p).catch((e=>{(0,b.processErrorResponse)(e)}))}),[r,k,p,d]),(0,s.useEffect)((()=>(w.delete?l():o(),()=>{w.delete&&o()})),[o,l,w.delete]),(0,s.useEffect)((()=>(w.quantity||p!==i?l():o(),()=>{(w.quantity||p!==i)&&o()})),[l,o,w.quantity,p,i]),{isPendingDelete:w.delete,quantity:i,setItemQuantity:m,removeItem:g,cartItemQuantityErrors:n}})(e),{dispatchStoreEvent:W}=(0,k.n)(),{receiveCart:Y,...J}=(0,c.b)(),z=(0,s.useMemo)((()=>({context:"cart",cartItem:e,cart:J})),[e,J]),G=(0,w.getCurrencyFromPriceResponse)(V),X=(0,g.applyCheckoutFilter)({filterName:"itemName",defaultValue:m,extensions:Z,arg:z}),ee=(0,N.Z)({amount:parseInt(V.raw_prices.regular_price,10),precision:V.raw_prices.precision}),te=(0,N.Z)({amount:parseInt(V.raw_prices.price,10),precision:V.raw_prices.precision}),re=ee.subtract(te),ae=re.multiply(U),ce=(0,w.getCurrencyFromPriceResponse)(Q);let ne=parseInt(Q.line_subtotal,10);(0,v.getSetting)("displayCartPricesIncludingTax",!1)&&(ne+=parseInt(Q.line_subtotal_tax,10));const le=(0,N.Z)({amount:ne,precision:ce.minorUnit}),oe=M.length?M[0]:{},se="hidden"===h||"search"===h,ie=(0,g.applyCheckoutFilter)({filterName:"cartItemClass",defaultValue:"",extensions:Z,arg:z}),me=(0,g.applyCheckoutFilter)({filterName:"cartItemPrice",defaultValue:"<price/>",extensions:Z,arg:z,validation:g.productPriceValidation}),ue=(0,g.applyCheckoutFilter)({filterName:"subtotalPriceFormat",defaultValue:"<price/>",extensions:Z,arg:z,validation:g.productPriceValidation}),pe=(0,g.applyCheckoutFilter)({filterName:"saleBadgePriceFormat",defaultValue:"<price/>",extensions:Z,arg:z,validation:g.productPriceValidation}),de=(0,g.applyCheckoutFilter)({filterName:"showRemoveItemLink",defaultValue:!0,extensions:Z,arg:z});return(0,a.createElement)("tr",{className:l()("wc-block-cart-items__row",ie,{"is-disabled":B}),ref:n,tabIndex:r},(0,a.createElement)("td",{className:"wc-block-cart-item__image","aria-hidden":!(0,f.objectHasProp)(oe,"alt")||!oe.alt},se?(0,a.createElement)(I,{image:oe,fallbackAlt:X}):(0,a.createElement)("a",{href:F,tabIndex:-1},(0,a.createElement)(I,{image:oe,fallbackAlt:X}))),(0,a.createElement)("td",{className:"wc-block-cart-item__product"},(0,a.createElement)("div",{className:"wc-block-cart-item__wrap"},(0,a.createElement)(_.Z,{disabled:B||se,name:X,permalink:F}),R?(0,a.createElement)(C,null):!!D&&(0,a.createElement)(x,{lowStockRemaining:D}),(0,a.createElement)("div",{className:"wc-block-cart-item__prices"},(0,a.createElement)(d.Z,{currency:G,regularPrice:O(ee,G),price:O(te,G),format:ue})),(0,a.createElement)($,{currency:G,saleAmount:O(re,G),format:pe}),(0,a.createElement)(H,{shortDescription:P,fullDescription:q,itemData:L,variation:T}),(0,a.createElement)("div",{className:"wc-block-cart-item__quantity"},!A&&!!S.editable&&(0,a.createElement)(p,{disabled:B,quantity:U,minimum:S.minimum,maximum:S.maximum,step:S.multiple_of,onChange:t=>{j(t),W("cart-set-item-quantity",{product:e,quantity:t})},itemName:X}),de&&(0,a.createElement)("button",{className:"wc-block-cart-item__remove-link","aria-label":(0,o.sprintf)(/* translators: %s refers to the item's name in the cart. */ /* translators: %s refers to the item's name in the cart. */
|
||
(0,o.__)("Remove %s from cart","woocommerce"),X),onClick:()=>{t(),K(),W("cart-remove-item",{product:e,quantity:U}),(0,i.speak)((0,o.sprintf)(/* translators: %s refers to the item name in the cart. */ /* translators: %s refers to the item name in the cart. */
|
||
(0,o.__)("%s has been removed from your cart.","woocommerce"),X))},disabled:B},(0,o.__)("Remove item","woocommerce"))))),(0,a.createElement)("td",{className:"wc-block-cart-item__total"},(0,a.createElement)("div",{className:"wc-block-cart-item__total-price-and-sale-badge-wrapper"},(0,a.createElement)(d.Z,{currency:ce,format:me,price:le.getAmount()}),U>1&&(0,a.createElement)($,{currency:G,saleAmount:O(ae,G),format:pe}))))}));r(9510);const Z=[...Array(3)].map(((_x,e)=>(0,a.createElement)(Q,{lineItem:{},key:e}))),U=e=>{const t={};return e.forEach((({key:e})=>{t[e]=(0,s.createRef)()})),t},j=({lineItems:e=[],isLoading:t=!1,className:r})=>{const c=(0,s.useRef)(null),n=(0,s.useRef)(U(e));(0,s.useEffect)((()=>{n.current=U(e)}),[e]);const i=e=>()=>{null!=n&&n.current&&e&&n.current[e].current instanceof HTMLElement?n.current[e].current.focus():c.current instanceof HTMLElement&&c.current.focus()},m=t?Z:e.map(((t,r)=>{const c=e.length>r+1?e[r+1].key:null;return(0,a.createElement)(Q,{key:t.key,lineItem:t,onRemove:i(c),ref:n.current[t.key],tabIndex:-1})}));return(0,a.createElement)("table",{className:l()("wc-block-cart-items",r),ref:c,tabIndex:-1},(0,a.createElement)("thead",null,(0,a.createElement)("tr",{className:"wc-block-cart-items__header"},(0,a.createElement)("th",{className:"wc-block-cart-items__header-image"},(0,a.createElement)("span",null,(0,o.__)("Product","woocommerce"))),(0,a.createElement)("th",{className:"wc-block-cart-items__header-product"},(0,a.createElement)("span",null,(0,o.__)("Details","woocommerce"))),(0,a.createElement)("th",{className:"wc-block-cart-items__header-total"},(0,a.createElement)("span",null,(0,o.__)("Total","woocommerce"))))),(0,a.createElement)("tbody",null,m))},K=({className:e})=>{const{cartItems:t,cartIsLoading:r}=(0,c.b)();return(0,a.createElement)(j,{className:e,lineItems:t,isLoading:r})}},9510:()=>{},2930:()=>{},3804:()=>{},6021:()=>{},333:()=>{},5437:()=>{},8968:()=>{}}]); |