@dropins/storefront-cart 0.4.0-alpha168 → 0.4.0-alpha169

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{jsx as r,jsxs as m,Fragment as j}from"@dropins/tools/preact-jsx-runtime.js";import*as o from"@dropins/tools/preact-compat.js";import{useState as _,useEffect as b}from"@dropins/tools/preact-compat.js";import{classes as O,VComponent as V,Slot as q}from"@dropins/tools/lib.js";/* empty css */import{E as mt}from"./EmptyCart.js";import{Divider as kt,Skeleton as vt,SkeletonRow as Lt,InLineAlert as Ct,Icon as X,CartList as B,CartItem as wt,Price as N,Image as It}from"@dropins/tools/components.js";import{s as St,g as Et}from"./resetCart.js";import{events as _t}from"@dropins/tools/event-bus.js";import{u as F}from"./updateProductsFromCart.js";import{useText as Ot}from"@dropins/tools/i18n.js";const J=u=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...u},o.createElement("g",{clipPath:"url(#clip0_4797_15331)"},o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M10.25 20.91L1.5 17.55V6.51996L10.25 9.92996V20.91Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.24023 4.64001L14.9902 8.06001V11.42",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{className:"error-icon",vectorEffect:"non-scaling-stroke",d:"M19 13.31L15.5 19.37H22.5L19 13.31Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{className:"error-icon",vectorEffect:"non-scaling-stroke",d:"M19.0202 17.11H18.9802L18.9502 15.56H19.0502L19.0202 17.11ZM18.9602 18.29V18.06H19.0502V18.29H18.9602Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19 12.16V6.51996L10.25 9.92996V20.91L14.27 19.37L14.4 19.32",stroke:"currentColor",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M1.5 6.51999L10.25 3.04999L19 6.51999L10.25 9.92999L1.5 6.51999Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),o.createElement("defs",null,o.createElement("clipPath",{id:"clip0_4797_15331"},o.createElement("rect",{width:22,height:18.86,fill:"white",transform:"translate(1 2.54999)"})))),Nt=u=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...u},o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),Pt=({className:u,children:Z,heading:d,emptyCart:k,products:f,outOfStockMessage:p,loading:P=!0,...g})=>r("div",{...g,className:O(["cart-cart-summary-list",u]),children:P?r(xt,{}):m(j,{children:[(d||p)&&m("div",{"data-testid":"cart-summary-list-heading-wrapper",className:O(["cart-cart-summary-list__heading",["cart-cart-summary-list__heading--full-width",!f]]),children:[d&&m(j,{children:[r(V,{node:d,className:"cart-cart-summary-list__heading-text"}),r(kt,{variant:"primary",className:O(["cart-cart-summary-list__heading-divider"])})]}),p&&r(V,{node:p,className:"cart-cart-summary-list__out-of-stock-message"})]}),r("div",{className:O(["cart-cart-summary-list__content",["cart-cart-summary-list__content--empty",!f]]),children:f||r(V,{node:k,className:"cart-cart-summary-list__empty-cart"})})]})}),xt=()=>r(vt,{"data-testid":"cart-summary-list-skeleton",className:"cart-cart-summary-list__skeleton",rowGap:"medium",children:r(Lt,{variant:"row",size:"xlarge",fullWidth:!0,lines:3,multilineGap:"small"})}),Qt=({initialData:u=null,hideHeading:Z,routeProduct:d,routeEmptyCartCTA:k,onItemUpdate:f,onItemRemove:p,maxItems:P,slots:g,attributesToHide:h=[],enableRemoveItem:x,enableUpdateItemQuantity:$,onItemsErrorsChange:Q,...K})=>{var U;const[Y,D]=_(!u),[a,R]=_(u),[v,tt]=_(new Set),[I,et]=_(new Map),c=(U=St.config)==null?void 0:U.shoppingCartDisplaySetting,i=Ot({file:"Cart.CartItem.file",files:"Cart.CartItem.files",heading:"Cart.Cart.heading",message:"Cart.CartItem.message",recipient:"Cart.CartItem.recipient",regularPrice:"Cart.CartItem.regularPrice",discountedPrice:"Cart.CartItem.discountedPrice",sender:"Cart.CartItem.sender",lowInventory:"Cart.CartItem.lowInventory",insufficientQuantity:"Cart.CartItem.insufficientQuantity",insufficientQuantityGeneral:"Cart.CartItem.insufficientQuantityGeneral",outOfStockHeading:"Cart.OutOfStockMessage.heading",outOfStockDescription:"Cart.OutOfStockMessage.message",outOfStockAlert:"Cart.OutOfStockMessage.alert",removeAction:"Cart.OutOfStockMessage.action",notAvailableMessage:"Cart.CartItem.notAvailableMessage"}),G=(t,e)=>{tt(n=>(e?n.add(t):n.delete(t),new Set(n)))},z=(t,e)=>{et(n=>(e?n.set(t,e):n.delete(t),new Map(n)))},A=(t,e)=>{G(t,!0),z(t),x&&e===0?F([{uid:t,quantity:e}]).then(()=>{p==null||p({uid:t})}).finally(()=>{G(t,!1)}).catch(n=>{console.warn(n)}):$&&F([{uid:t,quantity:e}]).then(()=>{f==null||f({uid:t,quantity:e})}).finally(()=>{G(t,!1)}).catch(n=>{console.warn(n),z(t,n.message)})};b(()=>{const t=_t.on("cart/data",e=>{R(e),D(!1)},{eager:!0});return()=>{t==null||t.off()}},[]),b(()=>{Q&&Q(I)},[I,Q]);const nt=(t,e)=>{if(h.includes("image"))return;const n=r(It,{"data-testid":"cart-list-item-image",loading:e<4?"eager":"lazy",src:t.image.src,alt:t.image.alt,width:"300",height:"300",params:{width:300}});return d?r("a",{href:d(t),children:n}):n},rt=t=>{if(!h.includes("name"))return r("span",{"data-testid":"cart-list-item-title",children:d?r("a",{href:d(t),children:t.name}):t.name})},at=t=>{if(!h.includes("configurations"))return{...t.bundleOptions,...t.selectedOptions,...t.customizableOptions,...t.recipient?{[i.recipient]:t.recipient}:null,...t.recipientEmail&&t.recipient?{[i.recipient]:`${t.recipient} (${t.recipientEmail})`}:null,...t.sender?{[i.sender]:t.sender}:null,...t.senderEmail&&t.sender?{[i.sender]:`${t.sender} (${t.senderEmail})`}:{},...t.message?{[i.message]:t.message}:null,...t.links&&t.links.count?t.links.count>1?{[i.files.replace("{count}",t.links.count.toString())]:t.links.result}:{[i.file.replace("{count}",t.links.count.toString())]:t.links.result}:null}},it=t=>{var e,n,l,s;return(c==null?void 0:c.price)==="INCLUDING_TAX"?t.discounted?{amount:t.regularPrice.value,currency:t.regularPrice.currency,style:{font:"inherit"},"data-testid":"including-tax-item-price"}:{amount:(e=t.taxedPrice)==null?void 0:e.value,currency:(n=t.taxedPrice)==null?void 0:n.currency,style:{font:"inherit"},"data-testid":"including-tax-item-price"}:{amount:(l=t.regularPrice)==null?void 0:l.value,currency:(s=t.regularPrice)==null?void 0:s.currency,style:{font:"inherit"},"data-testid":"regular-item-price"}},ct=t=>(c==null?void 0:c.price)==="INCLUDING_EXCLUDING_TAX"?r(N,{amount:t.rowTotal.value,currency:t.rowTotal.currency,"data-testid":"excluding-tax-total","aria-label":i.regularPrice}):void 0,ot=t=>{var l,s,y,E,L,C,w,H,M,W;const e={"aria-label":i.regularPrice},n=t.discounted?{}:null;return["INCLUDING_TAX","INCLUDING_EXCLUDING_TAX"].includes(c==null?void 0:c.price)?(e.amount=(l=t.rowTotalIncludingTax)==null?void 0:l.value,e.currency=(s=t.rowTotalIncludingTax)==null?void 0:s.currency,e.variant=t.discounted?"strikethrough":"default",e["data-testid"]="including-tax-item-total",n&&(e.amount=(y=t.total)==null?void 0:y.value,e.currency=(E=t.total)==null?void 0:E.currency,n.amount=(L=t.rowTotalIncludingTax)==null?void 0:L.value,n.currency=(C=t.rowTotalIncludingTax)==null?void 0:C.currency,n.sale=!0,n["aria-label"]=i.discountedPrice,n["data-testid"]="discount-total")):(e.amount=(w=t.total)==null?void 0:w.value,e.currency=(H=t.total)==null?void 0:H.currency,e.variant=t.discounted?"strikethrough":"default",e["data-testid"]="regular-item-total",n&&(n.amount=(M=t.discountedTotal)==null?void 0:M.value,n.currency=(W=t.discountedTotal)==null?void 0:W.currency,n.sale=!0,n["aria-label"]=i.regularPrice,n["data-testid"]="discount-total")),{totalProps:e,discountProps:n}},st=t=>{var L,C,w;if(h.includes("warning"))return;const e=I.get(t.uid),n=(L=I.get(t.uid))==null?void 0:L.includes("The requested qty is not available"),l=v.has(t.uid),s=t.insufficientQuantity&&t.stockLevel?t.stockLevel==="noNumber"?i.insufficientQuantityGeneral:i.insufficientQuantity.replace("{inventory}",(C=t.stockLevel)==null?void 0:C.toString()).replace("{count}",t.quantity.toString()):"",y=t.lowInventory&&t.onlyXLeftInStock&&i.lowInventory.replace("{count}",(w=t.onlyXLeftInStock)==null?void 0:w.toString()),E=!t.outOfStock&&e&&n?i.notAvailableMessage:e;return!l&&(e||t.insufficientQuantity||t.lowInventory)?m("span",{"data-testid":"item-warning",children:[r(X,{source:Nt,size:"16"}),E||s||y]}):void 0},lt=t=>h!=null&&h.includes("alert")?void 0:!v.has(t.uid)&&t.outOfStock?m("span",{"data-testid":"item-alert",children:[r(X,{source:J,size:"16"}),i.outOfStockAlert]}):void 0,ut=t=>r("span",{"data-testid":"cart-list-item-sku",children:t.sku}),T=t=>a!=null&&a.totalQuantity?a.items.filter(t).map((e,n)=>{const{totalProps:l,discountProps:s}=ot(e);return r(wt,{updating:v==null?void 0:v.has(e.uid),"data-testid":`cart-list-item-entry-${e.uid}`,image:nt(e,n),title:rt(e),sku:ut(e),price:r(N,{...it(e)}),quantity:e.quantity,total:m(j,{children:[r(N,{...l}),s&&r(N,{...s})]}),configurations:at(e),totalExcludingTax:ct(e),taxIncluded:(c==null?void 0:c.price)==="INCLUDING_TAX",taxExcluded:(c==null?void 0:c.price)==="INCLUDING_EXCLUDING_TAX",warning:st(e),alert:lt(e),onQuantity:$?y=>{A(e.uid,y)}:void 0,onRemove:x?()=>A(e.uid,0):void 0},e.uid)}):null,dt=r(q,{name:"EmptyCart",slot:g==null?void 0:g.EmptyCart,context:{},children:r(mt,{"data-testid":"empty-cart",ctaLinkURL:k==null?void 0:k()})}),gt=r(q,{name:"Heading",slot:g==null?void 0:g.Heading,context:{count:a==null?void 0:a.totalQuantity},children:r("div",{"data-testid":"default-cart-heading",children:i.heading.replace("({count})",a!=null&&a.totalQuantity?`(${a==null?void 0:a.totalQuantity.toString()})`:"")})}),ft=()=>{const t=a==null?void 0:a.items.filter(e=>e.outOfStock);t==null||t.forEach(e=>{A(e.uid,0)})},pt=T(t=>t.outOfStock||t.insufficientQuantity||!1),ht=a!=null&&a.hasOutOfStockItems?r(Ct,{"data-testid":"cart-out-of-stock-message",icon:r(X,{source:J,size:"16"}),itemList:r(B,{"data-testid":"out-of-stock-cart-items",children:pt}),type:"warning",heading:i.outOfStockHeading,description:i.outOfStockDescription,variant:"primary",actionButtonPosition:"bottom",additionalActions:a!=null&&a.hasFullyOutOfStockItems&&x?[{label:i.removeAction,onClick:ft}]:void 0}):void 0,S=T(t=>!t.outOfStock&&!t.insufficientQuantity),yt=a!=null&&a.totalQuantity?r(B,{"data-testid":"cart-list",children:S==null?void 0:S.slice(0,P??S.length)}):null;return r(Pt,{...K,heading:Z?void 0:gt,loading:Y,emptyCart:dt,products:yt,outOfStockMessage:ht})};Qt.getInitialData=async function(){return Et()};export{Qt as C};
1
+ import{jsx as r,jsxs as k,Fragment as j}from"@dropins/tools/preact-jsx-runtime.js";import*as o from"@dropins/tools/preact-compat.js";import{useState as _,useEffect as W}from"@dropins/tools/preact-compat.js";import{classes as O,VComponent as V,Slot as b}from"@dropins/tools/lib.js";/* empty css */import{E as kt}from"./EmptyCart.js";import{Divider as mt,Skeleton as vt,SkeletonRow as Lt,InLineAlert as Ct,Icon as X,CartList as B,CartItem as wt,Price as N,Image as It}from"@dropins/tools/components.js";import{s as St,g as Et}from"./resetCart.js";import{events as _t}from"@dropins/tools/event-bus.js";import{u as F}from"./updateProductsFromCart.js";import{useText as Ot}from"@dropins/tools/i18n.js";const J=u=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...u},o.createElement("g",{clipPath:"url(#clip0_4797_15331)"},o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M10.25 20.91L1.5 17.55V6.51996L10.25 9.92996V20.91Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.24023 4.64001L14.9902 8.06001V11.42",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{className:"error-icon",vectorEffect:"non-scaling-stroke",d:"M19 13.31L15.5 19.37H22.5L19 13.31Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{className:"error-icon",vectorEffect:"non-scaling-stroke",d:"M19.0202 17.11H18.9802L18.9502 15.56H19.0502L19.0202 17.11ZM18.9602 18.29V18.06H19.0502V18.29H18.9602Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19 12.16V6.51996L10.25 9.92996V20.91L14.27 19.37L14.4 19.32",stroke:"currentColor",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M1.5 6.51999L10.25 3.04999L19 6.51999L10.25 9.92999L1.5 6.51999Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),o.createElement("defs",null,o.createElement("clipPath",{id:"clip0_4797_15331"},o.createElement("rect",{width:22,height:18.86,fill:"white",transform:"translate(1 2.54999)"})))),Nt=u=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...u},o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),Pt=({className:u,children:Z,heading:d,emptyCart:m,products:f,outOfStockMessage:p,loading:P=!0,...g})=>r("div",{...g,className:O(["cart-cart-summary-list",u]),children:P?r(xt,{}):k(j,{children:[(d||p)&&k("div",{"data-testid":"cart-summary-list-heading-wrapper",className:O(["cart-cart-summary-list__heading",["cart-cart-summary-list__heading--full-width",!f]]),children:[d&&k(j,{children:[r(V,{node:d,className:"cart-cart-summary-list__heading-text"}),r(mt,{variant:"primary",className:O(["cart-cart-summary-list__heading-divider"])})]}),p&&r(V,{node:p,className:"cart-cart-summary-list__out-of-stock-message"})]}),r("div",{className:O(["cart-cart-summary-list__content",["cart-cart-summary-list__content--empty",!f]]),children:f||r(V,{node:m,className:"cart-cart-summary-list__empty-cart"})})]})}),xt=()=>r(vt,{"data-testid":"cart-summary-list-skeleton",className:"cart-cart-summary-list__skeleton",rowGap:"medium",children:r(Lt,{variant:"row",size:"xlarge",fullWidth:!0,lines:3,multilineGap:"small"})}),Qt=({initialData:u=null,hideHeading:Z,routeProduct:d,routeEmptyCartCTA:m,onItemUpdate:f,onItemRemove:p,maxItems:P,slots:g,attributesToHide:h=[],enableRemoveItem:x,enableUpdateItemQuantity:$,onItemsErrorsChange:Q,...K})=>{var U;const[Y,D]=_(!u),[a,R]=_(u),[v,tt]=_(new Set),[I,et]=_(new Map),c=(U=St.config)==null?void 0:U.shoppingCartDisplaySetting,i=Ot({file:"Cart.CartItem.file",files:"Cart.CartItem.files",heading:"Cart.Cart.heading",message:"Cart.CartItem.message",recipient:"Cart.CartItem.recipient",regularPrice:"Cart.CartItem.regularPrice",discountedPrice:"Cart.CartItem.discountedPrice",sender:"Cart.CartItem.sender",lowInventory:"Cart.CartItem.lowInventory",insufficientQuantity:"Cart.CartItem.insufficientQuantity",insufficientQuantityGeneral:"Cart.CartItem.insufficientQuantityGeneral",outOfStockHeading:"Cart.OutOfStockMessage.heading",outOfStockDescription:"Cart.OutOfStockMessage.message",outOfStockAlert:"Cart.OutOfStockMessage.alert",removeAction:"Cart.OutOfStockMessage.action",notAvailableMessage:"Cart.CartItem.notAvailableMessage"}),G=(t,e)=>{tt(n=>(e?n.add(t):n.delete(t),new Set(n)))},z=(t,e)=>{et(n=>(e?n.set(t,e):n.delete(t),new Map(n)))},A=(t,e)=>{G(t.uid,!0),z(t.uid),x&&e===0?F([{uid:t.uid,quantity:e}]).then(()=>{p==null||p({item:t})}).finally(()=>{G(t.uid,!1)}).catch(n=>{console.warn(n)}):$&&F([{uid:t.uid,quantity:e}]).then(()=>{f==null||f({item:t})}).finally(()=>{G(t.uid,!1)}).catch(n=>{console.warn(n),z(t.uid,n.message)})};W(()=>{const t=_t.on("cart/data",e=>{R(e),D(!1)},{eager:!0});return()=>{t==null||t.off()}},[]),W(()=>{Q&&Q(I)},[I,Q]);const nt=(t,e)=>{if(h.includes("image"))return;const n=r(It,{"data-testid":"cart-list-item-image",loading:e<4?"eager":"lazy",src:t.image.src,alt:t.image.alt,width:"300",height:"300",params:{width:300}});return d?r("a",{href:d(t),children:n}):n},rt=t=>{if(!h.includes("name"))return r("span",{"data-testid":"cart-list-item-title",children:d?r("a",{href:d(t),children:t.name}):t.name})},at=t=>{if(!h.includes("configurations"))return{...t.bundleOptions,...t.selectedOptions,...t.customizableOptions,...t.recipient?{[i.recipient]:t.recipient}:null,...t.recipientEmail&&t.recipient?{[i.recipient]:`${t.recipient} (${t.recipientEmail})`}:null,...t.sender?{[i.sender]:t.sender}:null,...t.senderEmail&&t.sender?{[i.sender]:`${t.sender} (${t.senderEmail})`}:{},...t.message?{[i.message]:t.message}:null,...t.links&&t.links.count?t.links.count>1?{[i.files.replace("{count}",t.links.count.toString())]:t.links.result}:{[i.file.replace("{count}",t.links.count.toString())]:t.links.result}:null}},it=t=>{var e,n,l,s;return(c==null?void 0:c.price)==="INCLUDING_TAX"?t.discounted?{amount:t.regularPrice.value,currency:t.regularPrice.currency,style:{font:"inherit"},"data-testid":"including-tax-item-price"}:{amount:(e=t.taxedPrice)==null?void 0:e.value,currency:(n=t.taxedPrice)==null?void 0:n.currency,style:{font:"inherit"},"data-testid":"including-tax-item-price"}:{amount:(l=t.regularPrice)==null?void 0:l.value,currency:(s=t.regularPrice)==null?void 0:s.currency,style:{font:"inherit"},"data-testid":"regular-item-price"}},ct=t=>(c==null?void 0:c.price)==="INCLUDING_EXCLUDING_TAX"?r(N,{amount:t.rowTotal.value,currency:t.rowTotal.currency,"data-testid":"excluding-tax-total","aria-label":i.regularPrice}):void 0,ot=t=>{var l,s,y,E,L,C,w,H,q,M;const e={"aria-label":i.regularPrice},n=t.discounted?{}:null;return["INCLUDING_TAX","INCLUDING_EXCLUDING_TAX"].includes(c==null?void 0:c.price)?(e.amount=(l=t.rowTotalIncludingTax)==null?void 0:l.value,e.currency=(s=t.rowTotalIncludingTax)==null?void 0:s.currency,e.variant=t.discounted?"strikethrough":"default",e["data-testid"]="including-tax-item-total",n&&(e.amount=(y=t.total)==null?void 0:y.value,e.currency=(E=t.total)==null?void 0:E.currency,n.amount=(L=t.rowTotalIncludingTax)==null?void 0:L.value,n.currency=(C=t.rowTotalIncludingTax)==null?void 0:C.currency,n.sale=!0,n["aria-label"]=i.discountedPrice,n["data-testid"]="discount-total")):(e.amount=(w=t.total)==null?void 0:w.value,e.currency=(H=t.total)==null?void 0:H.currency,e.variant=t.discounted?"strikethrough":"default",e["data-testid"]="regular-item-total",n&&(n.amount=(q=t.discountedTotal)==null?void 0:q.value,n.currency=(M=t.discountedTotal)==null?void 0:M.currency,n.sale=!0,n["aria-label"]=i.regularPrice,n["data-testid"]="discount-total")),{totalProps:e,discountProps:n}},st=t=>{var L,C,w;if(h.includes("warning"))return;const e=I.get(t.uid),n=(L=I.get(t.uid))==null?void 0:L.includes("The requested qty is not available"),l=v.has(t.uid),s=t.insufficientQuantity&&t.stockLevel?t.stockLevel==="noNumber"?i.insufficientQuantityGeneral:i.insufficientQuantity.replace("{inventory}",(C=t.stockLevel)==null?void 0:C.toString()).replace("{count}",t.quantity.toString()):"",y=t.lowInventory&&t.onlyXLeftInStock&&i.lowInventory.replace("{count}",(w=t.onlyXLeftInStock)==null?void 0:w.toString()),E=!t.outOfStock&&e&&n?i.notAvailableMessage:e;return!l&&(e||t.insufficientQuantity||t.lowInventory)?k("span",{"data-testid":"item-warning",children:[r(X,{source:Nt,size:"16"}),E||s||y]}):void 0},lt=t=>h!=null&&h.includes("alert")?void 0:!v.has(t.uid)&&t.outOfStock?k("span",{"data-testid":"item-alert",children:[r(X,{source:J,size:"16"}),i.outOfStockAlert]}):void 0,ut=t=>r("span",{"data-testid":"cart-list-item-sku",children:t.sku}),T=t=>a!=null&&a.totalQuantity?a.items.filter(t).map((e,n)=>{const{totalProps:l,discountProps:s}=ot(e);return r(wt,{updating:v==null?void 0:v.has(e.uid),"data-testid":`cart-list-item-entry-${e.uid}`,image:nt(e,n),title:rt(e),sku:ut(e),price:r(N,{...it(e)}),quantity:e.quantity,total:k(j,{children:[r(N,{...l}),s&&r(N,{...s})]}),configurations:at(e),totalExcludingTax:ct(e),taxIncluded:(c==null?void 0:c.price)==="INCLUDING_TAX",taxExcluded:(c==null?void 0:c.price)==="INCLUDING_EXCLUDING_TAX",warning:st(e),alert:lt(e),onQuantity:$?y=>{A(e,y)}:void 0,onRemove:x?()=>A(e,0):void 0},e.uid)}):null,dt=r(b,{name:"EmptyCart",slot:g==null?void 0:g.EmptyCart,context:{},children:r(kt,{"data-testid":"empty-cart",ctaLinkURL:m==null?void 0:m()})}),gt=r(b,{name:"Heading",slot:g==null?void 0:g.Heading,context:{count:a==null?void 0:a.totalQuantity},children:r("div",{"data-testid":"default-cart-heading",children:i.heading.replace("({count})",a!=null&&a.totalQuantity?`(${a==null?void 0:a.totalQuantity.toString()})`:"")})}),ft=()=>{const t=a==null?void 0:a.items.filter(e=>e.outOfStock);t==null||t.forEach(e=>{A(e,0)})},pt=T(t=>t.outOfStock||t.insufficientQuantity||!1),ht=a!=null&&a.hasOutOfStockItems?r(Ct,{"data-testid":"cart-out-of-stock-message",icon:r(X,{source:J,size:"16"}),itemList:r(B,{"data-testid":"out-of-stock-cart-items",children:pt}),type:"warning",heading:i.outOfStockHeading,description:i.outOfStockDescription,variant:"primary",actionButtonPosition:"bottom",additionalActions:a!=null&&a.hasFullyOutOfStockItems&&x?[{label:i.removeAction,onClick:ft}]:void 0}):void 0,S=T(t=>!t.outOfStock&&!t.insufficientQuantity),yt=a!=null&&a.totalQuantity?r(B,{"data-testid":"cart-list",children:S==null?void 0:S.slice(0,P??S.length)}):null;return r(Pt,{...K,heading:Z?void 0:gt,loading:Y,emptyCart:dt,products:yt,outOfStockMessage:ht})};Qt.getInitialData=async function(){return Et()};export{Qt as C};
@@ -6,12 +6,11 @@ export interface CartSummaryListProps extends HTMLAttributes<HTMLDivElement> {
6
6
  hideHeading?: boolean;
7
7
  routeProduct?: (item: CartModel['items'][0]) => string;
8
8
  routeEmptyCartCTA?: () => string;
9
- onItemUpdate?: ({ uid, quantity }: {
10
- uid: string;
11
- quantity: number;
9
+ onItemUpdate?: ({ item }: {
10
+ item: CartModel['items'][0];
12
11
  }) => void;
13
- onItemRemove?: ({ uid }: {
14
- uid: string;
12
+ onItemRemove?: ({ item }: {
13
+ item: CartModel['items'][0];
15
14
  }) => void;
16
15
  maxItems?: number;
17
16
  attributesToHide?: SwitchableAttributes[];
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-cart", "version": "0.4.0-alpha168", "@dropins/tools": "~0.27.0"}
1
+ {"name": "@dropins/storefront-cart", "version": "0.4.0-alpha169", "@dropins/tools": "~0.27.0"}