@dropins/storefront-cart 0.4.0-alpha130 → 0.4.0-alpha131

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.
package/api/index.d.ts CHANGED
@@ -10,4 +10,5 @@ export * from './getStoreConfig';
10
10
  export * from './getEstimateShipping';
11
11
  export * from './getEstimatedTotals';
12
12
  export * from './refreshCart';
13
+ export { getPersistedCartData as getCartDataFromCache } from '../lib/persisted-data';
13
14
  //# sourceMappingURL=index.d.ts.map
package/api.js CHANGED
@@ -1,4 +1,4 @@
1
- import{s}from"./chunks/state.js";import{C as T,a as l,t as f}from"./chunks/CartFragment.js";import{events as m}from"@dropins/tools/event-bus.js";import{f as p,h as g}from"./chunks/resetCart.js";import{g as v,r as Q,c as H,s as k,a as z,b as Y}from"./chunks/resetCart.js";import{a as I,b as h}from"./chunks/updateProductsFromCart.js";import{u as q}from"./chunks/updateProductsFromCart.js";import{c as _,g as E,a as A}from"./chunks/getStoreConfig.js";import{b as J,e as K,i as L,d as V}from"./chunks/getStoreConfig.js";import{g as X,b as Z,a as tt}from"./chunks/getEstimateShipping.js";import{g as at}from"./chunks/getEstimatedTotals.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const R=`
1
+ import{s}from"./chunks/state.js";import{g as v}from"./chunks/state.js";import{C as T,a as f,t as g}from"./chunks/CartFragment.js";import{events as m}from"@dropins/tools/event-bus.js";import{f as p,h as l}from"./chunks/resetCart.js";import{g as H,r as k,c as z,s as Y,a as j,b as q}from"./chunks/resetCart.js";import{a as h,b as I}from"./chunks/updateProductsFromCart.js";import{u as J}from"./chunks/updateProductsFromCart.js";import{c as _,g as E,a as A}from"./chunks/getStoreConfig.js";import{b as L,e as V,i as W,d as X}from"./chunks/getStoreConfig.js";import{g as tt,b as rt,a as at}from"./chunks/getEstimateShipping.js";import{g as st}from"./chunks/getEstimatedTotals.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const R=`
2
2
  mutation ADD_PRODUCTS_TO_CART_MUTATION(
3
3
  $cartId: String!,
4
4
  $cartItems: [CartItemInput!]!,
@@ -17,9 +17,9 @@ import{s}from"./chunks/state.js";import{C as T,a as l,t as f}from"./chunks/CartF
17
17
  }
18
18
  }
19
19
  }
20
- ${l}
21
- `,w=async r=>{let o=!1;const n=s.cartId||await O().then(e=>(o=!0,e));return p(R,{variables:{cartId:n,cartItems:r.map(({sku:e,parentSku:a,quantity:i,optionsUIDs:t,enteredOptions:c})=>({sku:e,parent_sku:a,quantity:i,selected_options:t,entered_options:c}))}}).then(({errors:e,data:a})=>{var c;const i=[...((c=a==null?void 0:a.addProductsToCart)==null?void 0:c.user_errors)??[],...e??[]];if(i.length>0)return g(i);const t=f(a.addProductsToCart.cart);if(m.emit("cart/updated",t),m.emit("cart/data",t),t){const d=t.items.filter(C=>r.some(({sku:u})=>u===C.sku));o?I(t,d,s.locale??"en-US"):h(t,d,s.locale??"en-US")}return t})},P=`
20
+ ${f}
21
+ `,F=async r=>{let o=!1;const n=s.cartId||await O().then(e=>(o=!0,e));return p(R,{variables:{cartId:n,cartItems:r.map(({sku:e,parentSku:a,quantity:c,optionsUIDs:t,enteredOptions:i})=>({sku:e,parent_sku:a,quantity:c,selected_options:t,entered_options:i}))}}).then(({errors:e,data:a})=>{var i;const c=[...((i=a==null?void 0:a.addProductsToCart)==null?void 0:i.user_errors)??[],...e??[]];if(c.length>0)return l(c);const t=g(a.addProductsToCart.cart);if(m.emit("cart/updated",t),m.emit("cart/data",t),t){const d=t.items.filter(C=>r.some(({sku:u})=>u===C.sku));o?h(t,d,s.locale??"en-US"):I(t,d,s.locale??"en-US")}return t})},P=`
22
22
  mutation CREATE_EMPTY_CART_MUTATION {
23
23
  createEmptyCart
24
24
  }
25
- `,O=async()=>{const{disableGuestCart:r}=_.getConfig();if(r)throw new Error("Guest cart is disabled");return await p(P).then(({data:o})=>{const n=o.createEmptyCart;return s.cartId=n,n})},F=async()=>{const r=s.authenticated?await E():await A();return m.emit("cart/updated",r),m.emit("cart/data",r),r};export{w as addProductsToCart,_ as config,O as createEmptyCart,p as fetchGraphQl,J as getCartData,v as getConfig,X as getCountries,E as getCustomerCartPayload,Z as getEstimateShipping,at as getEstimatedTotals,A as getGuestCartPayload,tt as getRegions,K as getStoreConfig,L as initialize,V as initializeCart,F as refreshCart,Q as removeFetchGraphQlHeader,H as resetCart,k as setEndpoint,z as setFetchGraphQlHeader,Y as setFetchGraphQlHeaders,q as updateProductsFromCart};
25
+ `,O=async()=>{const{disableGuestCart:r}=_.getConfig();if(r)throw new Error("Guest cart is disabled");return await p(P).then(({data:o})=>{const n=o.createEmptyCart;return s.cartId=n,n})},w=async()=>{const r=s.authenticated?await E():await A();return m.emit("cart/updated",r),m.emit("cart/data",r),r};export{F as addProductsToCart,_ as config,O as createEmptyCart,p as fetchGraphQl,L as getCartData,v as getCartDataFromCache,H as getConfig,tt as getCountries,E as getCustomerCartPayload,rt as getEstimateShipping,st as getEstimatedTotals,A as getGuestCartPayload,at as getRegions,V as getStoreConfig,W as initialize,X as initializeCart,w as refreshCart,k as removeFetchGraphQlHeader,z as resetCart,Y as setEndpoint,j as setFetchGraphQlHeader,q as setFetchGraphQlHeaders,J as updateProductsFromCart};
@@ -1 +1 @@
1
- import{jsx as r,jsxs as v,Fragment as j}from"@dropins/tools/preact-jsx-runtime.js";import*as c from"@dropins/tools/preact-compat.js";import{useState as N,useEffect as $}from"@dropins/tools/preact-compat.js";import{classes as k,VComponent as X,Slot as T}from"@dropins/tools/lib.js";/* empty css */import{IllustratedMessage as pt,Icon as x,Button as ht,Divider as yt,Skeleton as kt,SkeletonRow as vt,InLineAlert as Ct,CartList as q,CartItem as Lt,Price as O,Image as wt}from"@dropins/tools/components.js";import{useText as W}from"@dropins/tools/i18n.js";import{s as It,g as Et}from"./state.js";import{events as St}from"@dropins/tools/event-bus.js";const _t=s=>c.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},c.createElement("g",{clipPath:"url(#clip0_102_196)"},c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3601 18.16H6.5601L4.8801 3H2.3501M19.6701 19.59C19.6701 20.3687 19.0388 21 18.2601 21C17.4814 21 16.8501 20.3687 16.8501 19.59C16.8501 18.8113 17.4814 18.18 18.2601 18.18C19.0388 18.18 19.6701 18.8113 19.6701 19.59ZM7.42986 19.59C7.42986 20.3687 6.79858 21 6.01986 21C5.24114 21 4.60986 20.3687 4.60986 19.59C4.60986 18.8113 5.24114 18.18 6.01986 18.18C6.79858 18.18 7.42986 18.8113 7.42986 19.59Z",stroke:"currentColor",strokeLinejoin:"round"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.25 6.37L20.89 8.06L20.14 14.8H6.19",stroke:"currentColor",strokeLinejoin:"round"})),c.createElement("defs",null,c.createElement("clipPath",{id:"clip0_102_196"},c.createElement("rect",{vectorEffect:"non-scaling-stroke",width:19.29,height:19.5,fill:"white",transform:"translate(2.3501 2.25)"})))),B=s=>c.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},c.createElement("g",{clipPath:"url(#clip0_4797_15331)"},c.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"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.24023 4.64001L14.9902 8.06001V11.42",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),c.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"}),c.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"}),c.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"}),c.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"})),c.createElement("defs",null,c.createElement("clipPath",{id:"clip0_4797_15331"},c.createElement("rect",{width:22,height:18.86,fill:"white",transform:"translate(1 2.54999)"})))),Nt=s=>c.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},c.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"}),c.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"})),Ot=({className:s,children:P,ctaLinkURL:l,...m})=>{const u=W({emptyCart:"Cart.EmptyCart.heading",cta:"Cart.EmptyCart.cta"});return r("div",{...m,className:k(["cart-empty-cart",s]),children:r(pt,{className:k(["cart-empty-cart__wrapper",s]),"data-testid":"cart-empty-cart",heading:u.emptyCart,icon:r(x,{className:"cart-empty-cart__icon",source:_t}),action:l?r(ht,{"data-testid":"cart-empty-cart-button",size:"medium",variant:"primary",type:"submit",href:l,children:u.cta},"routeHome"):void 0})})},xt=({className:s,children:P,heading:l,emptyCart:m,products:u,outOfStockMessage:p,loading:Q=!0,...f})=>r("div",{...f,className:k(["cart-cart-summary-list",s]),children:Q?r(Pt,{}):v(j,{children:[(l||p)&&v("div",{"data-testid":"cart-summary-list-heading-wrapper",className:k(["cart-cart-summary-list__heading",["cart-cart-summary-list__heading--full-width",!u]]),children:[l&&v(j,{children:[r(X,{node:l,className:"cart-cart-summary-list__heading-text"}),r(yt,{variant:"primary",className:k(["cart-cart-summary-list__heading-divider"])})]}),p&&r(X,{node:p,className:"cart-cart-summary-list__out-of-stock-message"})]}),r("div",{className:k(["cart-cart-summary-list__content",["cart-cart-summary-list__content--empty",!u]]),children:u||r(X,{node:m,className:"cart-cart-summary-list__empty-cart"})})]})}),Pt=()=>r(kt,{"data-testid":"cart-summary-list-skeleton",className:"cart-cart-summary-list__skeleton",rowGap:"medium",children:r(vt,{variant:"row",size:"xlarge",fullWidth:!0,lines:3,multilineGap:"small"})}),Qt=({initialData:s=null,hideHeading:P,routeProduct:l,routeEmptyCartCTA:m,onItemQuantityUpdate:u,onItemRemove:p,maxItems:Q,slots:f,attributesToHide:h=[],onItemsErrorsChange:G,...F})=>{var H;const[R,J]=N(!s),[a,K]=N(s),[C,Y]=N(new Set),[E,D]=N(new Map),o=(H=It.config)==null?void 0:H.shoppingCartDisplaySetting,i=W({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"}),A=(t,e)=>{Y(n=>(e?n.add(t):n.delete(t),new Set(n)))},Z=(t,e)=>{D(n=>(e?n.set(t,e):n.delete(t),new Map(n)))},V=(t,e)=>{A(t,!0),Z(t),p&&e===0?p(t).finally(()=>{A(t,!1)}).catch(n=>{console.warn(n)}):u&&u(t,e).finally(()=>{A(t,!1)}).catch(n=>{console.warn(n),Z(t,n.message)})};$(()=>{const t=St.on("cart/data",e=>{K(e),J(!1)},{eager:!0});return()=>{t==null||t.off()}},[]),$(()=>{G&&G(E)},[E,G]);const tt=(t,e)=>{if(h.includes("image"))return;const n=r(wt,{"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 l?r("a",{href:l(t),children:n}):n},et=t=>{if(!h.includes("name"))return r("span",{"data-testid":"cart-list-item-title",children:l?r("a",{href:l(t),children:t.name}):t.name})},nt=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}},rt=t=>{var e,n,g,d;return(o==null?void 0:o.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:(g=t.regularPrice)==null?void 0:g.value,currency:(d=t.regularPrice)==null?void 0:d.currency,style:{font:"inherit"},"data-testid":"regular-item-price"}},at=t=>(o==null?void 0:o.price)==="INCLUDING_EXCLUDING_TAX"?r(O,{amount:t.rowTotal.value,currency:t.rowTotal.currency,"data-testid":"excluding-tax-total","aria-label":i.regularPrice}):void 0,ct=t=>{var g,d,y,_,L,w,I,M,U,z;const e={"aria-label":i.regularPrice},n=t.discounted?{}:null;return["INCLUDING_TAX","INCLUDING_EXCLUDING_TAX"].includes(o==null?void 0:o.price)?(e.amount=(g=t.rowTotalIncludingTax)==null?void 0:g.value,e.currency=(d=t.rowTotalIncludingTax)==null?void 0:d.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=(_=t.total)==null?void 0:_.currency,n.amount=(L=t.rowTotalIncludingTax)==null?void 0:L.value,n.currency=(w=t.rowTotalIncludingTax)==null?void 0:w.currency,n.sale=!0,n["aria-label"]=i.discountedPrice,n["data-testid"]="discount-total")):(e.amount=(I=t.total)==null?void 0:I.value,e.currency=(M=t.total)==null?void 0:M.currency,e.variant=t.discounted?"strikethrough":"default",e["data-testid"]="regular-item-total",n&&(n.amount=(U=t.discountedTotal)==null?void 0:U.value,n.currency=(z=t.discountedTotal)==null?void 0:z.currency,n.sale=!0,n["aria-label"]=i.regularPrice,n["data-testid"]="discount-total")),{totalProps:e,discountProps:n}},it=t=>{var L,w,I;if(h.includes("warning"))return;const e=E.get(t.uid),n=(L=E.get(t.uid))==null?void 0:L.includes("The requested qty is not available"),g=C.has(t.uid),d=t.insufficientQuantity&&t.stockLevel?t.stockLevel==="noNumber"?i.insufficientQuantityGeneral:i.insufficientQuantity.replace("{inventory}",(w=t.stockLevel)==null?void 0:w.toString()).replace("{count}",t.quantity.toString()):"",y=t.lowInventory&&t.onlyXLeftInStock&&i.lowInventory.replace("{count}",(I=t.onlyXLeftInStock)==null?void 0:I.toString()),_=!t.outOfStock&&e&&n?i.notAvailableMessage:e;return!g&&(e||t.insufficientQuantity||t.lowInventory)?v("span",{"data-testid":"item-warning",children:[r(x,{source:Nt,size:"16"}),_||d||y]}):void 0},ot=t=>h!=null&&h.includes("alert")?void 0:!C.has(t.uid)&&t.outOfStock?v("span",{"data-testid":"item-alert",children:[r(x,{source:B,size:"16"}),i.outOfStockAlert]}):void 0,st=t=>r("span",{"data-testid":"cart-list-item-sku",children:t.sku}),b=t=>a!=null&&a.totalQuantity?a.items.filter(t).map((e,n)=>{const{totalProps:g,discountProps:d}=ct(e);return r(Lt,{updating:C==null?void 0:C.has(e.uid),"data-testid":`cart-list-item-entry-${e.uid}`,image:tt(e,n),title:et(e),sku:st(e),price:r(O,{...rt(e)}),quantity:e.quantity,total:v(j,{children:[r(O,{...g}),d&&r(O,{...d})]}),configurations:nt(e),totalExcludingTax:at(e),taxIncluded:(o==null?void 0:o.price)==="INCLUDING_TAX",taxExcluded:(o==null?void 0:o.price)==="INCLUDING_EXCLUDING_TAX",warning:it(e),alert:ot(e),onQuantity:u?y=>{V(e.uid,y)}:void 0,onRemove:p?()=>V(e.uid,0):void 0},e.uid)}):null,lt=r(T,{name:"EmptyCart",slot:f==null?void 0:f.EmptyCart,context:{},children:r(Ot,{"data-testid":"empty-cart",ctaLinkURL:m==null?void 0:m()})}),ut=r(T,{name:"Heading",slot:f==null?void 0:f.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()})`:"")})}),dt=()=>{const t=a==null?void 0:a.items.filter(e=>e.outOfStock);t==null||t.forEach(e=>{V(e.uid,0)})},gt=b(t=>t.outOfStock||t.insufficientQuantity||!1),ft=a!=null&&a.hasOutOfStockItems?r(Ct,{"data-testid":"cart-out-of-stock-message",icon:r(x,{source:B,size:"16"}),itemList:r(q,{"data-testid":"out-of-stock-cart-items",children:gt}),type:"warning",heading:i.outOfStockHeading,description:i.outOfStockDescription,variant:"primary",actionButtonPosition:"bottom",additionalActions:a!=null&&a.hasFullyOutOfStockItems?[{label:i.removeAction,onClick:dt}]:void 0}):void 0,S=b(t=>!t.outOfStock&&!t.insufficientQuantity),mt=a!=null&&a.totalQuantity?r(q,{"data-testid":"cart-list",children:S==null?void 0:S.slice(0,Q??S.length)}):null;return r(xt,{...F,heading:P?void 0:ut,loading:R,emptyCart:lt,products:mt,outOfStockMessage:ft})};Qt.getInitialData=async function(){return Et()};export{Qt as C};
1
+ import{jsx as r,jsxs as y,Fragment as X}from"@dropins/tools/preact-jsx-runtime.js";import*as o from"@dropins/tools/preact-compat.js";import{useState as _,useEffect as q}from"@dropins/tools/preact-compat.js";import{classes as O,VComponent as A,Slot as H}from"@dropins/tools/lib.js";/* empty css */import{E as pt}from"./EmptyCart.js";import{Divider as mt,Skeleton as ht,SkeletonRow as yt,InLineAlert as kt,Icon as V,CartList as M,CartItem as vt,Price as N,Image as Lt}from"@dropins/tools/components.js";import{s as It,g as Ct}from"./state.js";import{events as wt}from"@dropins/tools/event-bus.js";import{useText as St}from"@dropins/tools/i18n.js";const W=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)"})))),Et=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"})),_t=({className:u,children:U,heading:d,emptyCart:k,products:f,outOfStockMessage:p,loading:x=!0,...g})=>r("div",{...g,className:O(["cart-cart-summary-list",u]),children:x?r(Ot,{}):y(X,{children:[(d||p)&&y("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&&y(X,{children:[r(A,{node:d,className:"cart-cart-summary-list__heading-text"}),r(mt,{variant:"primary",className:O(["cart-cart-summary-list__heading-divider"])})]}),p&&r(A,{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(A,{node:k,className:"cart-cart-summary-list__empty-cart"})})]})}),Ot=()=>r(ht,{"data-testid":"cart-summary-list-skeleton",className:"cart-cart-summary-list__skeleton",rowGap:"medium",children:r(yt,{variant:"row",size:"xlarge",fullWidth:!0,lines:3,multilineGap:"small"})}),Nt=({initialData:u=null,hideHeading:U,routeProduct:d,routeEmptyCartCTA:k,onItemQuantityUpdate:f,onItemRemove:p,maxItems:x,slots:g,attributesToHide:m=[],onItemsErrorsChange:P,...B})=>{var $;const[R,F]=_(!u),[a,J]=_(u),[v,K]=_(new Set),[w,Y]=_(new Map),c=($=It.config)==null?void 0:$.shoppingCartDisplaySetting,i=St({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"}),Q=(t,e)=>{K(n=>(e?n.add(t):n.delete(t),new Set(n)))},j=(t,e)=>{Y(n=>(e?n.set(t,e):n.delete(t),new Map(n)))},G=(t,e)=>{Q(t,!0),j(t),p&&e===0?p(t).finally(()=>{Q(t,!1)}).catch(n=>{console.warn(n)}):f&&f(t,e).finally(()=>{Q(t,!1)}).catch(n=>{console.warn(n),j(t,n.message)})};q(()=>{const t=wt.on("cart/data",e=>{J(e),F(!1)},{eager:!0});return()=>{t==null||t.off()}},[]),q(()=>{P&&P(w)},[w,P]);const D=(t,e)=>{if(m.includes("image"))return;const n=r(Lt,{"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},tt=t=>{if(!m.includes("name"))return r("span",{"data-testid":"cart-list-item-title",children:d?r("a",{href:d(t),children:t.name}):t.name})},et=t=>{if(!m.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}},nt=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"}},rt=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,at=t=>{var l,s,h,E,L,I,C,b,z,T;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=(h=t.total)==null?void 0:h.value,e.currency=(E=t.total)==null?void 0:E.currency,n.amount=(L=t.rowTotalIncludingTax)==null?void 0:L.value,n.currency=(I=t.rowTotalIncludingTax)==null?void 0:I.currency,n.sale=!0,n["aria-label"]=i.discountedPrice,n["data-testid"]="discount-total")):(e.amount=(C=t.total)==null?void 0:C.value,e.currency=(b=t.total)==null?void 0:b.currency,e.variant=t.discounted?"strikethrough":"default",e["data-testid"]="regular-item-total",n&&(n.amount=(z=t.discountedTotal)==null?void 0:z.value,n.currency=(T=t.discountedTotal)==null?void 0:T.currency,n.sale=!0,n["aria-label"]=i.regularPrice,n["data-testid"]="discount-total")),{totalProps:e,discountProps:n}},it=t=>{var L,I,C;if(m.includes("warning"))return;const e=w.get(t.uid),n=(L=w.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}",(I=t.stockLevel)==null?void 0:I.toString()).replace("{count}",t.quantity.toString()):"",h=t.lowInventory&&t.onlyXLeftInStock&&i.lowInventory.replace("{count}",(C=t.onlyXLeftInStock)==null?void 0:C.toString()),E=!t.outOfStock&&e&&n?i.notAvailableMessage:e;return!l&&(e||t.insufficientQuantity||t.lowInventory)?y("span",{"data-testid":"item-warning",children:[r(V,{source:Et,size:"16"}),E||s||h]}):void 0},ct=t=>m!=null&&m.includes("alert")?void 0:!v.has(t.uid)&&t.outOfStock?y("span",{"data-testid":"item-alert",children:[r(V,{source:W,size:"16"}),i.outOfStockAlert]}):void 0,ot=t=>r("span",{"data-testid":"cart-list-item-sku",children:t.sku}),Z=t=>a!=null&&a.totalQuantity?a.items.filter(t).map((e,n)=>{const{totalProps:l,discountProps:s}=at(e);return r(vt,{updating:v==null?void 0:v.has(e.uid),"data-testid":`cart-list-item-entry-${e.uid}`,image:D(e,n),title:tt(e),sku:ot(e),price:r(N,{...nt(e)}),quantity:e.quantity,total:y(X,{children:[r(N,{...l}),s&&r(N,{...s})]}),configurations:et(e),totalExcludingTax:rt(e),taxIncluded:(c==null?void 0:c.price)==="INCLUDING_TAX",taxExcluded:(c==null?void 0:c.price)==="INCLUDING_EXCLUDING_TAX",warning:it(e),alert:ct(e),onQuantity:f?h=>{G(e.uid,h)}:void 0,onRemove:p?()=>G(e.uid,0):void 0},e.uid)}):null,st=r(H,{name:"EmptyCart",slot:g==null?void 0:g.EmptyCart,context:{},children:r(pt,{"data-testid":"empty-cart",ctaLinkURL:k==null?void 0:k()})}),lt=r(H,{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()})`:"")})}),ut=()=>{const t=a==null?void 0:a.items.filter(e=>e.outOfStock);t==null||t.forEach(e=>{G(e.uid,0)})},dt=Z(t=>t.outOfStock||t.insufficientQuantity||!1),gt=a!=null&&a.hasOutOfStockItems?r(kt,{"data-testid":"cart-out-of-stock-message",icon:r(V,{source:W,size:"16"}),itemList:r(M,{"data-testid":"out-of-stock-cart-items",children:dt}),type:"warning",heading:i.outOfStockHeading,description:i.outOfStockDescription,variant:"primary",actionButtonPosition:"bottom",additionalActions:a!=null&&a.hasFullyOutOfStockItems?[{label:i.removeAction,onClick:ut}]:void 0}):void 0,S=Z(t=>!t.outOfStock&&!t.insufficientQuantity),ft=a!=null&&a.totalQuantity?r(M,{"data-testid":"cart-list",children:S==null?void 0:S.slice(0,x??S.length)}):null;return r(_t,{...B,heading:U?void 0:lt,loading:R,emptyCart:st,products:ft,outOfStockMessage:gt})};Nt.getInitialData=async function(){return Ct()};export{Nt as C};
@@ -0,0 +1 @@
1
+ import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{classes as o}from"@dropins/tools/lib.js";import{IllustratedMessage as i,Icon as s,Button as m}from"@dropins/tools/components.js";/* empty css */import*as t from"@dropins/tools/preact-compat.js";import{useText as l}from"@dropins/tools/i18n.js";const p=e=>t.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},t.createElement("g",{clipPath:"url(#clip0_102_196)"},t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3601 18.16H6.5601L4.8801 3H2.3501M19.6701 19.59C19.6701 20.3687 19.0388 21 18.2601 21C17.4814 21 16.8501 20.3687 16.8501 19.59C16.8501 18.8113 17.4814 18.18 18.2601 18.18C19.0388 18.18 19.6701 18.8113 19.6701 19.59ZM7.42986 19.59C7.42986 20.3687 6.79858 21 6.01986 21C5.24114 21 4.60986 20.3687 4.60986 19.59C4.60986 18.8113 5.24114 18.18 6.01986 18.18C6.79858 18.18 7.42986 18.8113 7.42986 19.59Z",stroke:"currentColor",strokeLinejoin:"round"}),t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.25 6.37L20.89 8.06L20.14 14.8H6.19",stroke:"currentColor",strokeLinejoin:"round"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_102_196"},t.createElement("rect",{vectorEffect:"non-scaling-stroke",width:19.29,height:19.5,fill:"white",transform:"translate(2.3501 2.25)"})))),g=({className:e,children:d,ctaLinkURL:a,...n})=>{const c=l({emptyCart:"Cart.EmptyCart.heading",cta:"Cart.EmptyCart.cta"});return r("div",{...n,className:o(["cart-empty-cart",e]),children:r(i,{className:o(["cart-empty-cart__wrapper",e]),"data-testid":"cart-empty-cart",heading:c.emptyCart,icon:r(s,{className:"cart-empty-cart__icon",source:p}),action:a?r(m,{"data-testid":"cart-empty-cart-button",size:"medium",variant:"primary",type:"submit",href:a,children:c.cta},"routeHome"):void 0})})};export{g as E};
@@ -1 +1 @@
1
- import{C as g,C as h}from"../chunks/MiniCart.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"../chunks/state.js";import"@dropins/tools/event-bus.js";/* empty css */import"@dropins/tools/components.js";import"@dropins/tools/i18n.js";import"../chunks/updateProductsFromCart.js";import"../chunks/CartFragment.js";import"../chunks/resetCart.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/CartSummaryList.js";import"../chunks/OrderSummary.js";import"../chunks/getEstimatedTotals.js";export{g as Cart,h as default};
1
+ import{C as h,C as j}from"../chunks/MiniCart.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"../chunks/state.js";import"@dropins/tools/event-bus.js";/* empty css */import"@dropins/tools/components.js";import"@dropins/tools/i18n.js";import"../chunks/updateProductsFromCart.js";import"../chunks/CartFragment.js";import"../chunks/resetCart.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/CartSummaryList.js";import"../chunks/EmptyCart.js";import"../chunks/OrderSummary.js";import"../chunks/getEstimatedTotals.js";export{h as Cart,j as default};
@@ -1 +1 @@
1
- import{C as f,C as u}from"../chunks/CartSummaryList.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";/* empty css */import"@dropins/tools/components.js";import"@dropins/tools/i18n.js";import"../chunks/state.js";import"@dropins/tools/event-bus.js";export{f as CartSummaryList,u as default};
1
+ import{C as u,C as d}from"../chunks/CartSummaryList.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";/* empty css */import"../chunks/EmptyCart.js";import"@dropins/tools/components.js";import"@dropins/tools/i18n.js";import"../chunks/state.js";import"@dropins/tools/event-bus.js";export{u as CartSummaryList,d as default};
@@ -0,0 +1,8 @@
1
+ import { HTMLAttributes } from 'preact/compat';
2
+ import { Container } from '@dropins/tools/types/elsie/src/lib';
3
+
4
+ export interface EmptyCartProps extends HTMLAttributes<HTMLDivElement> {
5
+ ctaLinkURL?: string;
6
+ }
7
+ export declare const EmptyCart: Container<EmptyCartProps>;
8
+ //# sourceMappingURL=EmptyCart.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './EmptyCart';
2
+ export { EmptyCart as default } from './EmptyCart';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './EmptyCart/index'
2
+ import _default from './EmptyCart/index'
3
+ export default _default
@@ -0,0 +1 @@
1
+ import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";/* empty css */import{E as m}from"../chunks/EmptyCart.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";import"@dropins/tools/i18n.js";const E=({ctaLinkURL:t})=>r(m,{ctaLinkURL:t});export{E as EmptyCart,E as default};
@@ -1 +1 @@
1
- import{M as b,M as c}from"../chunks/MiniCart.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"../chunks/state.js";import"@dropins/tools/event-bus.js";/* empty css */import"@dropins/tools/components.js";import"@dropins/tools/i18n.js";import"../chunks/updateProductsFromCart.js";import"../chunks/CartFragment.js";import"../chunks/resetCart.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/CartSummaryList.js";import"../chunks/OrderSummary.js";import"../chunks/getEstimatedTotals.js";export{b as MiniCart,c as default};
1
+ import{M as c,M as g}from"../chunks/MiniCart.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"../chunks/state.js";import"@dropins/tools/event-bus.js";/* empty css */import"@dropins/tools/components.js";import"@dropins/tools/i18n.js";import"../chunks/updateProductsFromCart.js";import"../chunks/CartFragment.js";import"../chunks/resetCart.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/CartSummaryList.js";import"../chunks/EmptyCart.js";import"../chunks/OrderSummary.js";import"../chunks/getEstimatedTotals.js";export{c as MiniCart,g as default};
@@ -3,4 +3,5 @@ export * from './EstimateShipping';
3
3
  export * from './MiniCart';
4
4
  export * from './CartSummaryList';
5
5
  export * from './OrderSummary';
6
+ export * from './EmptyCart';
6
7
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-cart", "version": "0.4.0-alpha130", "@dropins/tools": "~0.27.0"}
1
+ {"name": "@dropins/storefront-cart", "version": "0.4.0-alpha131", "@dropins/tools": "~0.27.0"}