@dropins/storefront-cart 0.7.0-alpha010 → 0.7.0-alpha012
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/chunks/CartFragment.js +10 -17
- package/chunks/CartSummaryList.js +1 -1
- package/chunks/MiniCart.js +1 -1
- package/containers/Cart/Cart.d.ts +7 -0
- package/containers/CartSummaryList/CartSummaryList.d.ts +7 -1
- package/containers/MiniCart/MiniCart.d.ts +2 -0
- package/data/models/cart-model.d.ts +2 -0
- package/data/transforms/__fixtures__/productTypesData.d.ts +61 -1
- package/i18n/en_US.json.d.ts +3 -1
- package/package.json +1 -1
- package/render.js +1 -1
package/chunks/CartFragment.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s}from"./resetCart.js";function
|
|
1
|
+
import{s as _}from"./resetCart.js";function V(r){var n,u,e,l,c,t,o;return r?{id:r.id,totalQuantity:z(r),errors:S(r==null?void 0:r.itemsV2),items:h(r==null?void 0:r.itemsV2),miniCartMaxItems:h(r==null?void 0:r.itemsV2).slice(0,((n=_.config)==null?void 0:n.miniCartMaxItemsDisplay)??10),total:{includingTax:{value:r.prices.grand_total.value,currency:r.prices.grand_total.currency},excludingTax:{value:r.prices.grand_total_excluding_tax.value,currency:r.prices.grand_total_excluding_tax.currency}},subtotal:{excludingTax:{value:(u=r.prices.subtotal_excluding_tax)==null?void 0:u.value,currency:(e=r.prices.subtotal_excluding_tax)==null?void 0:e.currency},includingTax:{value:(l=r.prices.subtotal_including_tax)==null?void 0:l.value,currency:(c=r.prices.subtotal_including_tax)==null?void 0:c.currency},includingDiscountOnly:{value:(t=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:t.value,currency:(o=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:o.currency}},appliedTaxes:I(r.prices.applied_taxes),totalTax:k(r.prices.applied_taxes,r.prices.grand_total.currency),appliedDiscounts:I(r.prices.discounts),isVirtual:r.is_virtual,addresses:{shipping:r.shipping_addresses&&P(r)},isGuestCart:!_.authenticated,hasOutOfStockItems:M(r),hasFullyOutOfStockItems:$(r)}:null}function k(r,n){return r!=null&&r.length?r.reduce((u,e)=>({value:u.value+e.amount.value,currency:e.amount.currency}),{value:0,currency:n}):{value:0,currency:n}}function h(r){var u;if(!((u=r==null?void 0:r.items)!=null&&u.length))return[];const n=_.config;return r.items.map(e=>{var l,c,t,o,i,s,a,g,f,m,y,v,b,d,C,x;return{itemType:e.__typename,uid:e.uid,url:{urlKey:e.product.url_key,categories:e.product.categories.map(O=>O.url_key)},quantity:e.quantity,sku:e.product.sku,name:e.product.name,image:{src:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.url:((c=(l=e.configured_variant)==null?void 0:l.thumbnail)==null?void 0:c.url)||e.product.thumbnail.url,alt:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.label:((o=(t=e.configured_variant)==null?void 0:t.thumbnail)==null?void 0:o.label)||e.product.thumbnail.label},price:{value:e.prices.price.value,currency:e.prices.price.currency},taxedPrice:{value:e.prices.price_including_tax.value,currency:e.prices.price_including_tax.currency},rowTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},rowTotalIncludingTax:{value:e.prices.row_total_including_tax.value,currency:e.prices.row_total_including_tax.currency},links:G(e.links),total:e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0||e.__typename==="BundleCartItem"?{value:e.prices.row_total.value,currency:e.prices.row_total.currency}:{value:(i=e.prices.original_row_total)==null?void 0:i.value,currency:(s=e.prices.original_row_total)==null?void 0:s.currency},discount:{value:e.prices.total_item_discount.value,currency:e.prices.total_item_discount.currency},regularPrice:e.__typename==="ConfigurableCartItem"?{value:(g=(a=e.configured_variant)==null?void 0:a.price_range)==null?void 0:g.maximum_price.regular_price.value,currency:(m=(f=e.configured_variant)==null?void 0:f.price_range)==null?void 0:m.maximum_price.regular_price.currency}:e.__typename==="GiftCardCartItem"||e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0||e.__typename==="BundleCartItem"?{value:e.prices.price.value,currency:e.prices.price.currency}:{value:(y=e.product.price_range)==null?void 0:y.maximum_price.regular_price.value,currency:(v=e.product.price_range)==null?void 0:v.maximum_price.regular_price.currency},discounted:e.__typename==="BundleCartItem"||e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0?!1:e.__typename==="ConfigurableCartItem"?((d=(b=e.configured_variant)==null?void 0:b.price_range)==null?void 0:d.maximum_price.discount.amount_off)>0:((C=e.product.price_range)==null?void 0:C.maximum_price.discount.amount_off)>0,bundleOptions:e.__typename==="BundleCartItem"?w(e.bundle_options):null,selectedOptions:E(e.configurable_options),customizableOptions:A(e.customizable_options),sender:e.__typename==="GiftCardCartItem"?e.sender_name:null,senderEmail:e.__typename==="GiftCardCartItem"?e.sender_email:null,recipient:e.__typename==="GiftCardCartItem"?e.recipient_name:null,recipientEmail:e.__typename==="GiftCardCartItem"?e.recipient_email:null,message:e.__typename==="GiftCardCartItem"?e.message:null,discountedTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},onlyXLeftInStock:e.__typename==="ConfigurableCartItem"?(x=e.configured_variant)==null?void 0:x.only_x_left_in_stock:e.product.only_x_left_in_stock,lowInventory:e.is_available&&e.product.only_x_left_in_stock!==null,insufficientQuantity:(e.__typename==="ConfigurableCartItem"?e.configured_variant:e.product).stock_status==="IN_STOCK"&&!e.is_available,outOfStock:e.product.stock_status==="OUT_OF_STOCK",stockLevel:N(e),discountPercentage:D(e),savingsAmount:F(e)}})}function S(r){var u;const n=(u=r==null?void 0:r.items)==null?void 0:u.reduce((e,l)=>{var c;return(c=l.errors)==null||c.forEach(t=>{e.push({uid:l.uid,text:t.message})}),e},[]);return n!=null&&n.length?n:null}function I(r){return r!=null&&r.length?r.map(n=>({amount:{value:n.amount.value,currency:n.amount.currency},label:n.label})):[]}function w(r){const n=r==null?void 0:r.map(e=>({uid:e.uid,label:e.label,value:e.values.map(l=>l.label).join(", ")})),u={};return n==null||n.forEach(e=>{u[e.label]=e.value}),Object.keys(u).length>0?u:null}function E(r){const n=r==null?void 0:r.map(e=>({uid:e.configurable_product_option_uid,label:e.option_label,value:e.value_label})),u={};return n==null||n.forEach(e=>{u[e.label]=e.value}),Object.keys(u).length>0?u:null}function A(r){const n=r==null?void 0:r.map(e=>({uid:e.customizable_option_uid,label:e.label,type:e.type,values:e.values.map(l=>({uid:l.customizable_option_value_uid,label:l.label,value:l.value}))})),u={};return n==null||n.forEach(e=>{var l;switch(e.type){case"field":case"area":case"date_time":u[e.label]=e.values[0].value;break;case"radio":case"drop_down":u[e.label]=e.values[0].label;break;case"multiple":case"checkbox":u[e.label]=e.values.reduce((s,a)=>s?`${s}, ${a.label}`:a.label,"");break;case"file":const c=new DOMParser,t=e.values[0].value,i=((l=c.parseFromString(t,"text/html").querySelector("a"))==null?void 0:l.textContent)||"";u[e.label]=i;break}}),u}function z(r){var n,u;return((n=_.config)==null?void 0:n.cartSummaryDisplayTotal)===0?r.itemsV2.items.length:((u=_.config)==null?void 0:u.cartSummaryDisplayTotal)===1?r.total_quantity:r.itemsV2.items.length}function G(r){return(r==null?void 0:r.length)>0?{count:r.length,result:r.map(n=>n.title).join(", ")}:null}function P(r){var n,u,e,l;return(n=r.shipping_addresses)!=null&&n.length?(u=r.shipping_addresses)==null?void 0:u.map(c=>({countryCode:c.country.code,zipCode:c.postcode,regionCode:c.region.code})):(e=r.addresses)!=null&&e.length?(l=r.addresses)==null?void 0:l.filter(c=>c.default_shipping).map(c=>{var t;return c.default_shipping&&{countryCode:c.country_id,zipCode:c.postcode,regionCode:(t=c.region)==null?void 0:t.region_code}}):null}function M(r){var n,u;return(u=(n=r==null?void 0:r.itemsV2)==null?void 0:n.items)==null?void 0:u.some(e=>{var l;return((l=e==null?void 0:e.product)==null?void 0:l.stock_status)==="OUT_OF_STOCK"||e.product.stock_status==="IN_STOCK"&&!e.is_available})}function N(r){if(!r.not_available_message)return null;const n=r.not_available_message.match(/-?\d+/);return n?parseInt(n[0]):"noNumber"}function $(r){var n,u;return(u=(n=r==null?void 0:r.itemsV2)==null?void 0:n.items)==null?void 0:u.some(e=>{var l;return((l=e==null?void 0:e.product)==null?void 0:l.stock_status)==="OUT_OF_STOCK"})}function D(r){var u,e,l,c,t,o,i,s;let n;if(r.__typename==="ConfigurableCartItem")n=(c=(l=(e=(u=r==null?void 0:r.configured_variant)==null?void 0:u.price_range)==null?void 0:e.maximum_price)==null?void 0:l.discount)==null?void 0:c.percent_off;else{if(r.__typename==="BundleCartItem")return;n=(s=(i=(o=(t=r==null?void 0:r.product)==null?void 0:t.price_range)==null?void 0:o.maximum_price)==null?void 0:i.discount)==null?void 0:s.percent_off}if(n!==0)return Math.round(n)}function F(r){var e,l,c,t,o,i;let n,u;if(n=((l=(e=r==null?void 0:r.prices)==null?void 0:e.original_row_total)==null?void 0:l.value)-((t=(c=r==null?void 0:r.prices)==null?void 0:c.row_total)==null?void 0:t.value),u=(i=(o=r==null?void 0:r.prices)==null?void 0:o.row_total)==null?void 0:i.currency,n!==0)return{value:n,currency:u}}const p=`
|
|
2
2
|
customizable_options {
|
|
3
3
|
type
|
|
4
4
|
customizable_option_uid
|
|
@@ -14,7 +14,7 @@ import{s}from"./resetCart.js";function D(r){var n,u,e,l,c,t,a;return r?{id:r.id,
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
`,
|
|
17
|
+
`,T=`
|
|
18
18
|
price_range {
|
|
19
19
|
minimum_price {
|
|
20
20
|
regular_price {
|
|
@@ -45,7 +45,7 @@ import{s}from"./resetCart.js";function D(r){var n,u,e,l,c,t,a;return r?{id:r.id,
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
`,
|
|
48
|
+
`,B=`
|
|
49
49
|
fragment CartFragment on Cart {
|
|
50
50
|
id
|
|
51
51
|
total_quantity
|
|
@@ -107,13 +107,6 @@ fragment CartFragment on Cart {
|
|
|
107
107
|
value
|
|
108
108
|
currency
|
|
109
109
|
}
|
|
110
|
-
discounts {
|
|
111
|
-
amount {
|
|
112
|
-
value
|
|
113
|
-
currency
|
|
114
|
-
}
|
|
115
|
-
label
|
|
116
|
-
}
|
|
117
110
|
total_item_discount {
|
|
118
111
|
value
|
|
119
112
|
currency
|
|
@@ -158,10 +151,10 @@ fragment CartFragment on Cart {
|
|
|
158
151
|
}
|
|
159
152
|
only_x_left_in_stock
|
|
160
153
|
stock_status
|
|
161
|
-
${
|
|
154
|
+
${T}
|
|
162
155
|
}
|
|
163
156
|
...on SimpleCartItem {
|
|
164
|
-
${
|
|
157
|
+
${p}
|
|
165
158
|
}
|
|
166
159
|
... on ConfigurableCartItem {
|
|
167
160
|
configurable_options {
|
|
@@ -178,16 +171,16 @@ fragment CartFragment on Cart {
|
|
|
178
171
|
label
|
|
179
172
|
url
|
|
180
173
|
}
|
|
181
|
-
${
|
|
174
|
+
${T}
|
|
182
175
|
}
|
|
183
|
-
${
|
|
176
|
+
${p}
|
|
184
177
|
}
|
|
185
178
|
... on DownloadableCartItem {
|
|
186
179
|
links {
|
|
187
180
|
sort_order
|
|
188
181
|
title
|
|
189
182
|
}
|
|
190
|
-
${
|
|
183
|
+
${p}
|
|
191
184
|
}
|
|
192
185
|
... on BundleCartItem {
|
|
193
186
|
bundle_options {
|
|
@@ -227,7 +220,7 @@ fragment CartFragment on Cart {
|
|
|
227
220
|
$pageSize: Int! = 100,
|
|
228
221
|
$currentPage: Int! = 1,
|
|
229
222
|
$itemsSortInput: QuoteItemsSortInput! = {field: CREATED_AT, order: DESC}
|
|
230
|
-
`,
|
|
223
|
+
`,U=`
|
|
231
224
|
customer {
|
|
232
225
|
addresses {
|
|
233
226
|
default_shipping
|
|
@@ -239,4 +232,4 @@ customer {
|
|
|
239
232
|
region_id
|
|
240
233
|
}
|
|
241
234
|
}
|
|
242
|
-
}`;export{q as C,
|
|
235
|
+
}`;export{q as C,B as a,U as b,V as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r,jsxs as k,Fragment as Z}from"@dropins/tools/preact-jsx-runtime.js";import*as s from"@dropins/tools/preact-compat.js";import{useState as _,useEffect as T}from"@dropins/tools/preact-compat.js";import{classes as x,VComponent as V,Slot as X}from"@dropins/tools/lib.js";/* empty css */import{E as mt}from"./EmptyCart.js";import{Divider as vt,Skeleton as Lt,SkeletonRow as Ct,InLineAlert as wt,Icon as j,CartList as D,CartItem as It,Price as O,Image as Et}from"@dropins/tools/components.js";import{g as St}from"./persisted-data.js";import{events as _t}from"@dropins/tools/event-bus.js";import{s as xt}from"./resetCart.js";import{u as J}from"./updateProductsFromCart.js";import{useText as Ot}from"@dropins/tools/i18n.js";const K=g=>s.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...g},s.createElement("g",{clipPath:"url(#clip0_4797_15331)"},s.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"}),s.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.24023 4.64001L14.9902 8.06001V11.42",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),s.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"}),s.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"}),s.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"}),s.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"})),s.createElement("defs",null,s.createElement("clipPath",{id:"clip0_4797_15331"},s.createElement("rect",{width:22,height:18.86,fill:"white",transform:"translate(1 2.54999)"})))),Nt=g=>s.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...g},s.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"}),s.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:g,children:$,heading:f,emptyCart:m,products:p,outOfStockMessage:h,loading:N=!0,...l})=>r("div",{...l,className:x(["cart-cart-summary-list",g]),children:N?r(Qt,{}):k(Z,{children:[(f||h)&&k("div",{"data-testid":"cart-summary-list-heading-wrapper",className:x(["cart-cart-summary-list__heading",["cart-cart-summary-list__heading--full-width",!p]]),children:[f&&k(Z,{children:[r(V,{node:f,className:"cart-cart-summary-list__heading-text"}),r(vt,{variant:"primary",className:x(["cart-cart-summary-list__heading-divider"])})]}),h&&r(V,{node:h,className:"cart-cart-summary-list__out-of-stock-message"})]}),r("div",{className:x(["cart-cart-summary-list__content",["cart-cart-summary-list__content--empty",!p]]),children:p||r(V,{node:m,className:"cart-cart-summary-list__empty-cart"})})]})}),Qt=()=>r(Lt,{"data-testid":"cart-summary-list-skeleton",className:"cart-cart-summary-list__skeleton",rowGap:"medium",children:r(Ct,{variant:"row",size:"xlarge",fullWidth:!0,lines:3,multilineGap:"small"})}),Gt=({initialData:g=null,hideHeading:$,routeProduct:f,routeEmptyCartCTA:m,onItemUpdate:p,onItemRemove:h,maxItems:N,slots:l,attributesToHide:o=[],enableRemoveItem:P,enableUpdateItemQuantity:z,onItemsErrorsChange:Q,...Y})=>{var q;const[R,H]=_(!g),[a,b]=_(g),[v,tt]=_(new Set),[I,et]=_(new Map),c=(q=xt.config)==null?void 0:q.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)))},F=(t,e)=>{et(n=>(e?n.set(t,e):n.delete(t),new Map(n)))},A=(t,e)=>{G(t.uid,!0),F(t.uid),P&&e===0?J([{uid:t.uid,quantity:e}]).then(()=>{h==null||h({item:t})}).finally(()=>{G(t.uid,!1)}).catch(n=>{console.warn(n)}):z&&J([{uid:t.uid,quantity:e}]).then(()=>{p==null||p({item:t})}).finally(()=>{G(t.uid,!1)}).catch(n=>{console.warn(n),F(t.uid,n.message)})};T(()=>{const t=_t.on("cart/data",e=>{b(e),H(!1)},{eager:!0});return()=>{t==null||t.off()}},[]),T(()=>{Q&&Q(I)},[I,Q]);const nt=(t,e)=>{if(o.includes("image"))return;const n=r(Et,{"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 f?r("a",{href:f(t),children:n}):n},rt=t=>{if(!o.includes("name"))return r("span",{"data-testid":"cart-list-item-title",children:f?r("a",{href:f(t),children:t.name}):t.name})},at=t=>{if(!o.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,d,u;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:(d=t.regularPrice)==null?void 0:d.value,currency:(u=t.regularPrice)==null?void 0:u.currency,style:{font:"inherit"},"data-testid":"regular-item-price"}},ct=t=>(c==null?void 0:c.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,ot=t=>{var d,u,y,S,L,C,w,M,W,B;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=(d=t.rowTotalIncludingTax)==null?void 0:d.value,e.currency=(u=t.rowTotalIncludingTax)==null?void 0:u.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=(S=t.total)==null?void 0:S.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=(M=t.total)==null?void 0:M.currency,e.variant=t.discounted?"strikethrough":"default",e["data-testid"]="regular-item-total",n&&(n.amount=(W=t.discountedTotal)==null?void 0:W.value,n.currency=(B=t.discountedTotal)==null?void 0:B.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(o.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"),d=v.has(t.uid),u=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()),S=!t.outOfStock&&e&&n?i.notAvailableMessage:e;return!d&&(e||t.insufficientQuantity||t.lowInventory)?k("span",{"data-testid":"item-warning",children:[r(j,{source:Nt,size:"16"}),S||u||y]}):void 0},lt=t=>o!=null&&o.includes("alert")?void 0:!v.has(t.uid)&&t.outOfStock?k("span",{"data-testid":"item-alert",children:[r(j,{source:K,size:"16"}),i.outOfStockAlert]}):void 0,ut=t=>{if(!o.includes("sku"))return r("span",{"data-testid":"cart-list-item-sku",children:t.sku})},dt=t=>r(X,{name:"Footer",slot:l==null?void 0:l.Footer,context:{item:t}}),U=t=>a!=null&&a.totalQuantity?a.items.filter(t).map((e,n)=>{const{totalProps:d,discountProps:u}=ot(e);return r(It,{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:o.includes("price")?void 0:r(O,{...it(e)}),quantity:o.includes("quantity")?void 0:e.quantity,total:k(Z,{children:[o.includes("total")?void 0:r(O,{...d}),o.includes("totalDiscount")?void 0:u&&r(O,{...u})]}),configurations:at(e),totalExcludingTax:o.includes("totalExcludingTax")?void 0:ct(e),taxIncluded:(c==null?void 0:c.price)==="INCLUDING_TAX",taxExcluded:!o.includes("totalExcludingTax")&&(c==null?void 0:c.price)==="INCLUDING_EXCLUDING_TAX",warning:st(e),alert:lt(e),onQuantity:z?y=>{A(e,y)}:void 0,onRemove:P?()=>A(e,0):void 0,footer:dt(e)},e.uid)}):null,gt=r(X,{name:"EmptyCart",slot:l==null?void 0:l.EmptyCart,context:{},children:r(mt,{"data-testid":"empty-cart",ctaLinkURL:m==null?void 0:m()})}),ft=r(X,{name:"Heading",slot:l==null?void 0:l.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()})`:"")})}),pt=()=>{const t=a==null?void 0:a.items.filter(e=>e.outOfStock);t==null||t.forEach(e=>{A(e,0)})},ht=U(t=>t.outOfStock||t.insufficientQuantity||!1),yt=a!=null&&a.hasOutOfStockItems?r(wt,{"data-testid":"cart-out-of-stock-message",icon:r(j,{source:K,size:"16"}),itemList:r(D,{"data-testid":"out-of-stock-cart-items",children:ht}),type:"warning",heading:i.outOfStockHeading,description:i.outOfStockDescription,variant:"primary",actionButtonPosition:"bottom",additionalActions:a!=null&&a.hasFullyOutOfStockItems&&P?[{label:i.removeAction,onClick:pt}]:void 0}):void 0,E=U(t=>!t.outOfStock&&!t.insufficientQuantity),kt=a!=null&&a.totalQuantity?r(D,{"data-testid":"cart-list",children:E==null?void 0:E.slice(0,N??E.length)}):null;return r(Pt,{...Y,heading:$?void 0:ft,loading:R,emptyCart:gt,products:kt,outOfStockMessage:yt})};Gt.getInitialData=async function(){return St()};export{Gt as C};
|
|
1
|
+
import{jsx as r,jsxs as v,Fragment as j}from"@dropins/tools/preact-jsx-runtime.js";import*as s from"@dropins/tools/preact-compat.js";import{useState as O,useEffect as F}from"@dropins/tools/preact-compat.js";import{classes as P,VComponent as V,Slot as T}from"@dropins/tools/lib.js";/* empty css */import{E as It}from"./EmptyCart.js";import{Divider as wt,Skeleton as St,SkeletonRow as Et,InLineAlert as _t,Icon as X,CartList as D,CartItem as Ot,Price as S,Image as Pt}from"@dropins/tools/components.js";import{g as xt}from"./persisted-data.js";import{events as Nt}from"@dropins/tools/event-bus.js";import{s as At}from"./resetCart.js";import{u as J}from"./updateProductsFromCart.js";import{useText as Qt}from"@dropins/tools/i18n.js";const K=d=>s.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d},s.createElement("g",{clipPath:"url(#clip0_4797_15331)"},s.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"}),s.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.24023 4.64001L14.9902 8.06001V11.42",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),s.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"}),s.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"}),s.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"}),s.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"})),s.createElement("defs",null,s.createElement("clipPath",{id:"clip0_4797_15331"},s.createElement("rect",{width:22,height:18.86,fill:"white",transform:"translate(1 2.54999)"})))),Gt=d=>s.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d},s.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"}),s.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"})),Vt=({className:d,children:Z,heading:g,emptyCart:k,products:p,outOfStockMessage:h,loading:x=!0,...f})=>r("div",{...f,className:P(["cart-cart-summary-list",d]),children:x?r(Xt,{}):v(j,{children:[(g||h)&&v("div",{"data-testid":"cart-summary-list-heading-wrapper",className:P(["cart-cart-summary-list__heading",["cart-cart-summary-list__heading--full-width",!p]]),children:[g&&v(j,{children:[r(V,{node:g,className:"cart-cart-summary-list__heading-text"}),r(wt,{variant:"primary",className:P(["cart-cart-summary-list__heading-divider"])})]}),h&&r(V,{node:h,className:"cart-cart-summary-list__out-of-stock-message"})]}),r("div",{className:P(["cart-cart-summary-list__content",["cart-cart-summary-list__content--empty",!p]]),children:p||r(V,{node:k,className:"cart-cart-summary-list__empty-cart"})})]})}),Xt=()=>r(St,{"data-testid":"cart-summary-list-skeleton",className:"cart-cart-summary-list__skeleton",rowGap:"medium",children:r(Et,{variant:"row",size:"xlarge",fullWidth:!0,lines:3,multilineGap:"small"})}),jt=({initialData:d=null,hideHeading:Z,routeProduct:g,routeEmptyCartCTA:k,onItemUpdate:p,onItemRemove:h,maxItems:x,slots:f,attributesToHide:o=[],enableRemoveItem:N,enableUpdateItemQuantity:$,onItemsErrorsChange:A,showDiscount:Y,showSavings:R,quantityType:H,dropdownOptions:b,...tt})=>{var q;const[nt,et]=O(!d),[a,rt]=O(d),[C,at]=O(new Set),[E,it]=O(new Map),c=(q=At.config)==null?void 0:q.shoppingCartDisplaySetting,i=Qt({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",discountPercent:"Cart.CartItem.discountPercentage",savingsAmount:"Cart.CartItem.savingsAmount"}),Q=(t,n)=>{at(e=>(n?e.add(t):e.delete(t),new Set(e)))},z=(t,n)=>{it(e=>(n?e.set(t,n):e.delete(t),new Map(e)))},G=(t,n)=>{Q(t.uid,!0),z(t.uid),N&&n===0?J([{uid:t.uid,quantity:n}]).then(()=>{h==null||h({item:t})}).finally(()=>{Q(t.uid,!1)}).catch(e=>{console.warn(e)}):$&&J([{uid:t.uid,quantity:n}]).then(()=>{p==null||p({item:t})}).finally(()=>{Q(t.uid,!1)}).catch(e=>{console.warn(e),z(t.uid,e.message)})};F(()=>{const t=Nt.on("cart/data",n=>{rt(n),et(!1)},{eager:!0});return()=>{t==null||t.off()}},[]),F(()=>{A&&A(E)},[E,A]);const ct=(t,n)=>{if(o.includes("image"))return;const e=r(Pt,{"data-testid":"cart-list-item-image",loading:n<4?"eager":"lazy",src:t.image.src,alt:t.image.alt,width:"300",height:"300",params:{width:300}});return g?r("a",{href:g(t),children:e}):e},ot=t=>{if(!o.includes("name"))return r("span",{"data-testid":"cart-list-item-title",children:g?r("a",{href:g(t),children:t.name}):t.name})},st=t=>{if(o.includes("configurations"))return;const n={...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};if(Object.keys(n).length!==0)return n},lt=t=>{var n,e,u,l;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:(n=t.taxedPrice)==null?void 0:n.value,currency:(e=t.taxedPrice)==null?void 0:e.currency,style:{font:"inherit"},"data-testid":"including-tax-item-price"}:{amount:(u=t.regularPrice)==null?void 0:u.value,currency:(l=t.regularPrice)==null?void 0:l.currency,style:{font:"inherit"},"data-testid":"regular-item-price"}},ut=t=>{var n,e;return{amount:(n=t.savingsAmount)==null?void 0:n.value,currency:(e=t.savingsAmount)==null?void 0:e.currency,style:{font:"inherit"},"data-testid":"item-savings-amount"}},dt=t=>(c==null?void 0:c.price)==="INCLUDING_EXCLUDING_TAX"?r(S,{amount:t.rowTotal.value,currency:t.rowTotal.currency,"data-testid":"excluding-tax-total","aria-label":i.regularPrice}):void 0,gt=t=>{var u,l,y,m,L,I,w,M,W,B;const n={"aria-label":i.regularPrice},e=t.discounted?{}:null;return["INCLUDING_TAX","INCLUDING_EXCLUDING_TAX"].includes(c==null?void 0:c.price)?(n.amount=(u=t.rowTotalIncludingTax)==null?void 0:u.value,n.currency=(l=t.rowTotalIncludingTax)==null?void 0:l.currency,n.variant=t.discounted?"strikethrough":"default",n["data-testid"]="including-tax-item-total",e&&(n.amount=(y=t.total)==null?void 0:y.value,n.currency=(m=t.total)==null?void 0:m.currency,e.amount=(L=t.rowTotalIncludingTax)==null?void 0:L.value,e.currency=(I=t.rowTotalIncludingTax)==null?void 0:I.currency,e.sale=!0,e["aria-label"]=i.discountedPrice,e["data-testid"]="discount-total")):(n.amount=(w=t.total)==null?void 0:w.value,n.currency=(M=t.total)==null?void 0:M.currency,n.variant=t.discounted?"strikethrough":"default",n["data-testid"]="regular-item-total",e&&(e.amount=(W=t.discountedTotal)==null?void 0:W.value,e.currency=(B=t.discountedTotal)==null?void 0:B.currency,e.sale=!0,e["aria-label"]=i.regularPrice,e["data-testid"]="discount-total")),{totalProps:n,discountProps:e}},ft=t=>{var L,I,w;if(o.includes("warning"))return;const n=E.get(t.uid),e=(L=E.get(t.uid))==null?void 0:L.includes("The requested qty is not available"),u=C.has(t.uid),l=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()):"",y=t.lowInventory&&t.onlyXLeftInStock&&i.lowInventory.replace("{count}",(w=t.onlyXLeftInStock)==null?void 0:w.toString()),m=!t.outOfStock&&n&&e?i.notAvailableMessage:n;return!u&&(n||t.insufficientQuantity||t.lowInventory)?v("span",{"data-testid":"item-warning",children:[r(X,{source:Gt,size:"16"}),m||l||y]}):void 0},pt=t=>o!=null&&o.includes("alert")?void 0:!C.has(t.uid)&&t.outOfStock?v("span",{"data-testid":"item-alert",children:[r(X,{source:K,size:"16"}),i.outOfStockAlert]}):void 0,ht=t=>{if(!o.includes("sku"))return r("span",{"data-testid":"cart-list-item-sku",children:t.sku})},U=t=>a!=null&&a.totalQuantity?a.items.filter(t).map((n,e)=>{var y;const{totalProps:u,discountProps:l}=gt(n);return r(Ot,{updating:C==null?void 0:C.has(n.uid),"data-testid":`cart-list-item-entry-${n.uid}`,image:ct(n,e),title:ot(n),sku:ht(n),price:o.includes("price")?void 0:r(S,{...lt(n)}),quantity:o.includes("quantity")?void 0:n.quantity,total:v(j,{children:[o.includes("total")?void 0:r(S,{...u}),o.includes("totalDiscount")?void 0:l&&r(S,{...l})]}),configurations:st(n),totalExcludingTax:o.includes("totalExcludingTax")?void 0:dt(n),taxIncluded:(c==null?void 0:c.price)==="INCLUDING_TAX",taxExcluded:!o.includes("totalExcludingTax")&&(c==null?void 0:c.price)==="INCLUDING_EXCLUDING_TAX",warning:ft(n),alert:pt(n),quantityType:H,dropdownOptions:b,onQuantity:$?m=>{G(n,m)}:void 0,onRemove:N?()=>G(n,0):void 0,discount:Y&&n.discounted&&n.discountPercentage?r("div",{"data-testid":"item-discount-percent",children:i.discountPercent.replace("{discount}",((y=n.discountPercentage)==null?void 0:y.toString())??"")}):void 0,savings:R&&n.discounted&&n.savingsAmount?v("div",{children:[r("span",{children:r(S,{...ut(n)})})," ",i.savingsAmount]}):void 0},n.uid)}):null,yt=r(T,{name:"EmptyCart",slot:f==null?void 0:f.EmptyCart,context:{},children:r(It,{"data-testid":"empty-cart",ctaLinkURL:k==null?void 0:k()})}),vt=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()})`:"")})}),mt=()=>{const t=a==null?void 0:a.items.filter(n=>n.outOfStock);t==null||t.forEach(n=>{G(n,0)})},kt=U(t=>t.outOfStock||t.insufficientQuantity||!1),Ct=a!=null&&a.hasOutOfStockItems?r(_t,{"data-testid":"cart-out-of-stock-message",icon:r(X,{source:K,size:"16"}),itemList:r(D,{"data-testid":"out-of-stock-cart-items",children:kt}),type:"warning",heading:i.outOfStockHeading,description:i.outOfStockDescription,variant:"primary",actionButtonPosition:"bottom",additionalActions:a!=null&&a.hasFullyOutOfStockItems&&N?[{label:i.removeAction,onClick:mt}]:void 0}):void 0,_=U(t=>!t.outOfStock&&!t.insufficientQuantity),Lt=a!=null&&a.totalQuantity?r(D,{"data-testid":"cart-list",children:_==null?void 0:_.slice(0,x??_.length)}):null;return r(Vt,{...tt,heading:Z?void 0:vt,loading:nt,emptyCart:yt,products:Lt,outOfStockMessage:Ct})};jt.getInitialData=async function(){return xt()};export{jt as C};
|
package/chunks/MiniCart.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as h,Fragment as X}from"@dropins/tools/preact-jsx-runtime.js";import{useState as Q,useEffect as C,useCallback as j}from"@dropins/tools/preact-compat.js";import{classes as b,VComponent as f,Slot as S}from"@dropins/tools/lib.js";import{g as D}from"./persisted-data.js";import{events as O}from"@dropins/tools/event-bus.js";/* empty css */import{Price as P,Button as T}from"@dropins/tools/components.js";import{useText as R}from"@dropins/tools/i18n.js";import{s as _}from"./resetCart.js";import{a as w,b as A}from"./acdl.js";import{u as G}from"./updateProductsFromCart.js";import"./CartSummaryGrid.js";import{C as H}from"./CartSummaryList.js";import"./OrderSummary.js";const F=({className:y,products:n,orderSummary:i,empty:r,...c})=>e("div",{...c,className:b(["cart-cart",y]),children:h("div",{className:b(["cart-cart__wrapper"]),children:[e("div",{"data-testid":"cart-content",className:b(["cart-cart__content",["cart-cart__content--empty",r||i==null],["cart-cart__content--full-width",r||i==null]]),children:n&&e(f,{node:n})}),n&&i&&e(f,{node:i,className:b(["cart-cart__order-summary"])})]})}),V=({className:y,products:n,subtotal:i,subtotalExcludingTaxes:r,ctas:c,...m})=>{const d=R({subtotal:"Cart.MiniCart.subtotal",subtotalExcludingTaxes:"Cart.MiniCart.subtotalExcludingTaxes"});return e("div",{...m,className:b(["cart-mini-cart",y]),children:n&&h(X,{children:[e("div",{className:"cart-mini-cart__products","data-testid":"mini-cart-products-wrapper",children:n}),h("div",{className:"cart-mini-cart__footer","data-testid":"mini-cart-subtotals",children:[i&&h("div",{className:"cart-mini-cart__footer__estimated-total","data-testid":"mini-cart-subtotal",children:[d.subtotal,e(f,{node:i})]}),r&&h("div",{className:"cart-mini-cart__footer__estimated-total-excluding-taxes","data-testid":"mini-cart-subtotal-excluding-taxes",children:[d.subtotalExcludingTaxes,e(f,{node:r,className:b(["dropin-price-summary__price","dropin-price-summary__price--muted"])})]}),c&&e(f,{node:c,className:"cart-mini-cart__footer__ctas"})]})]})})},$=({children:y,routeProduct:n,routeEmptyCartCTA:i,slots:r,showDiscount:c,showSavings:m,quantityType:d,dropdownOptions:I,initialData:s=null,...L})=>{const[t,N]=Q(s),[a,x]=Q(new Map),g={hasErrors:a.size>0},v=(o,p)=>G([{uid:o,quantity:p}]);C(()=>{const o=O.on("cart/data",p=>{N(p)},{eager:!0});return()=>{o==null||o.off()}},[]),C(()=>{s&&Object.keys(s).length>0&&w(s,_.locale??"en-US")},[s]);const u=r!=null&&r.OrderSummary?e(S,{name:"OrderSummary",slot:r.OrderSummary,context:{...g}}):void 0,k=o=>v(o,0),U=e(S,{name:"ProductList",slot:r==null?void 0:r.ProductList,context:{itemQuantityUpdateHandler:v,itemRemoveHandler:k},children:e(H,{"data-testid":"default-cart-summary-list",routeProduct:n,routeEmptyCartCTA:i,initialData:t,enableRemoveItem:!0,enableUpdateItemQuantity:!0,onItemsErrorsChange:x,showDiscount:c,showSavings:m,quantityType:d,dropdownOptions:I})});return e(F,{...L,empty:((t==null?void 0:t.items)&&t.items.length===0)??!0,orderSummary:u,products:U})};$.getInitialData=async function(){return D()};const z=({children:y,initialData:n=null,slots:i,routeProduct:r,routeCart:c,routeCheckout:m,routeEmptyCartCTA:d,showDiscount:I,showSavings:s,...L})=>{var p,M;const[t,N]=Q(n),a=(p=_.config)==null?void 0:p.shoppingCartDisplaySetting;C(()=>{const l=O.on("cart/data",E=>{N(E)},{eager:!0});return()=>{l==null||l.off()}},[]);const x=R({cartLink:"Cart.MiniCart.cartLink",checkoutLink:"Cart.MiniCart.checkoutLink"}),g=(l,E)=>G([{uid:l,quantity:E}]),v=l=>g(l,0),u=t==null?void 0:t.hasOutOfStockItems,k=j(()=>{t&&!u&&A(t,_.locale)},[t,u]);C(()=>{n&&Object.keys(n).length>0&&w(n,_.locale||"en-US")},[n]);const U=e(S,{name:"ProductList",slot:i==null?void 0:i.ProductList,context:{itemQuantityUpdateHandler:g,itemRemoveHandler:v,totalQuantity:t==null?void 0:t.totalQuantity},children:e(H,{"data-testid":"default-cart-summary-list",routeProduct:r,routeEmptyCartCTA:d,initialData:t,maxItems:(M=_.config)==null?void 0:M.miniCartMaxItemsDisplay,hideHeading:!(t!=null&&t.totalQuantity),enableRemoveItem:!0,showDiscount:I,showSavings:s})}),o=()=>(a==null?void 0:a.subtotal)==="INCLUDING_TAX"||(a==null?void 0:a.subtotal)==="INCLUDING_EXCLUDING_TAX"?{amount:t==null?void 0:t.subtotal.includingTax.value,currency:t==null?void 0:t.subtotal.includingTax.currency,"data-testid":"subtotal-including-tax",style:{font:"inherit"}}:{amount:t==null?void 0:t.subtotal.excludingTax.value,currency:t==null?void 0:t.subtotal.excludingTax.currency,"data-testid":"subtotal-excluding-tax",style:{font:"inherit"}};return e(V,{...L,subtotal:t!=null&&t.totalQuantity?(t==null?void 0:t.subtotal)&&e(P,{...o()}):void 0,subtotalExcludingTaxes:t!=null&&t.totalQuantity?(t==null?void 0:t.subtotal)&&((a==null?void 0:a.subtotal)==="INCLUDING_EXCLUDING_TAX"?e(P,{amount:t==null?void 0:t.subtotal.excludingTax.value,currency:t==null?void 0:t.subtotal.excludingTax.currency,"data-testid":"subtotal-including-excluding-tax",style:{font:"inherit"}}):void 0):void 0,ctas:t!=null&&t.totalQuantity?h("div",{children:[m&&e(T,{"data-testid":"route-checkout-button",variant:"primary",href:u?void 0:m(),disabled:u,"aria-disabled":u,onClick:k,children:x.checkoutLink}),c&&e(T,{"data-testid":"route-cart-button",variant:"tertiary",href:c(),children:x.cartLink})]}):void 0,products:U})};z.getInitialData=async function(){return D()};export{$ as C,z as M};
|
|
@@ -12,6 +12,13 @@ export interface CartProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
12
12
|
OrderSummary?: SlotProps<DefaultSlotContext>;
|
|
13
13
|
ProductList?: SlotProps;
|
|
14
14
|
};
|
|
15
|
+
showDiscount?: boolean;
|
|
16
|
+
showSavings?: boolean;
|
|
17
|
+
quantityType?: 'stepper' | 'dropdown';
|
|
18
|
+
dropdownOptions?: {
|
|
19
|
+
value: string;
|
|
20
|
+
text: string;
|
|
21
|
+
}[];
|
|
15
22
|
}
|
|
16
23
|
export declare const Cart: Container<CartProps, CartModel | null>;
|
|
17
24
|
export {};
|
|
@@ -17,11 +17,17 @@ export interface CartSummaryListProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
17
17
|
slots?: {
|
|
18
18
|
Heading?: SlotProps;
|
|
19
19
|
EmptyCart?: SlotProps;
|
|
20
|
-
Footer?: SlotProps;
|
|
21
20
|
};
|
|
22
21
|
enableRemoveItem?: boolean;
|
|
23
22
|
enableUpdateItemQuantity?: boolean;
|
|
24
23
|
onItemsErrorsChange?: (errors: Map<string, string>) => void;
|
|
24
|
+
showDiscount?: boolean;
|
|
25
|
+
showSavings?: boolean;
|
|
26
|
+
quantityType?: 'stepper' | 'dropdown';
|
|
27
|
+
dropdownOptions?: {
|
|
28
|
+
value: string;
|
|
29
|
+
text: string;
|
|
30
|
+
}[];
|
|
25
31
|
}
|
|
26
32
|
export type SwitchableAttributes = 'name' | 'image' | 'configurations' | 'warning' | 'alert' | 'sku' | 'price' | 'quantity' | 'total' | 'totalDiscount' | 'totalExcludingTax';
|
|
27
33
|
export declare const CartSummaryList: Container<CartSummaryListProps, CartModel | null>;
|
|
@@ -10,6 +10,8 @@ export interface MiniCartProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
10
10
|
slots?: {
|
|
11
11
|
ProductList?: SlotProps;
|
|
12
12
|
};
|
|
13
|
+
showDiscount?: boolean;
|
|
14
|
+
showSavings?: boolean;
|
|
13
15
|
}
|
|
14
16
|
export declare const MiniCart: Container<MiniCartProps, CartModel | null>;
|
|
15
17
|
//# sourceMappingURL=MiniCart.d.ts.map
|
|
@@ -940,5 +940,65 @@ declare const complexInsufficientQuantityGeneralMessage: {
|
|
|
940
940
|
};
|
|
941
941
|
};
|
|
942
942
|
};
|
|
943
|
-
|
|
943
|
+
declare const simpleWithNoDiscount: {
|
|
944
|
+
prices: {
|
|
945
|
+
row_total: {
|
|
946
|
+
value: number;
|
|
947
|
+
currency: string;
|
|
948
|
+
};
|
|
949
|
+
original_row_total: {
|
|
950
|
+
value: number;
|
|
951
|
+
currency: string;
|
|
952
|
+
};
|
|
953
|
+
price: {
|
|
954
|
+
value: number;
|
|
955
|
+
currency: string;
|
|
956
|
+
};
|
|
957
|
+
total_item_discount: {
|
|
958
|
+
value: number;
|
|
959
|
+
currency: string;
|
|
960
|
+
};
|
|
961
|
+
price_including_tax: {
|
|
962
|
+
value: number;
|
|
963
|
+
currency: string;
|
|
964
|
+
};
|
|
965
|
+
row_total_including_tax: {
|
|
966
|
+
value: number;
|
|
967
|
+
};
|
|
968
|
+
};
|
|
969
|
+
product: {
|
|
970
|
+
price_range: {
|
|
971
|
+
maximum_price: {
|
|
972
|
+
regular_price: {
|
|
973
|
+
value: number;
|
|
974
|
+
currency: string;
|
|
975
|
+
};
|
|
976
|
+
final_price: {
|
|
977
|
+
value: number;
|
|
978
|
+
currency: string;
|
|
979
|
+
};
|
|
980
|
+
discount: {
|
|
981
|
+
amount_off: number;
|
|
982
|
+
percent_off: number;
|
|
983
|
+
};
|
|
984
|
+
};
|
|
985
|
+
};
|
|
986
|
+
name: string;
|
|
987
|
+
sku: string;
|
|
988
|
+
thumbnail: {
|
|
989
|
+
url: string;
|
|
990
|
+
label: string;
|
|
991
|
+
};
|
|
992
|
+
url_key: string;
|
|
993
|
+
url_suffix: string;
|
|
994
|
+
categories: {
|
|
995
|
+
url_path: string;
|
|
996
|
+
url_key: string;
|
|
997
|
+
}[];
|
|
998
|
+
};
|
|
999
|
+
uid: string;
|
|
1000
|
+
quantity: number;
|
|
1001
|
+
errors: null;
|
|
1002
|
+
};
|
|
1003
|
+
export { bundleOptions, bundleOptionsEmpty, giftCardPhysical, giftCardVirtual, simple, simpleCustomizable, configurable, configurableCustomizable, giftCard, downloadbleWithMultipleLinks, simpleLowInventory, complexInsufficientQuantity, complexInsufficientQuantityGeneralMessage, simpleWithNoDiscount, };
|
|
944
1004
|
//# sourceMappingURL=productTypesData.d.ts.map
|
package/i18n/en_US.json.d.ts
CHANGED
|
@@ -78,7 +78,9 @@ declare const _default: {
|
|
|
78
78
|
"lowInventory": "Only {count} left!",
|
|
79
79
|
"insufficientQuantity": "Only {inventory} of {count} in stock",
|
|
80
80
|
"insufficientQuantityGeneral": "Not enough items for sale",
|
|
81
|
-
"notAvailableMessage": "Requested qty. not available"
|
|
81
|
+
"notAvailableMessage": "Requested qty. not available",
|
|
82
|
+
"discountPercentage": "{discount}% off",
|
|
83
|
+
"savingsAmount": "Savings"
|
|
82
84
|
},
|
|
83
85
|
"EstimateShipping": {
|
|
84
86
|
"label": "Shipping",
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-cart", "version": "0.7.0-
|
|
1
|
+
{"name": "@dropins/storefront-cart", "version": "0.7.0-alpha012", "@dropins/tools": "0.32.0-alpha3"}
|
package/render.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
(function(i,r){try{if(typeof document<"u"){const a=document.createElement("style"),n=r.styleId;for(const t in r.attributes)a.setAttribute(t,r.attributes[t]);a.setAttribute("data-dropin",n),a.appendChild(document.createTextNode(i));const e=document.querySelector('style[data-dropin="sdk"]');if(e)e.after(a);else{const t=document.querySelector('link[rel="stylesheet"], style');t?t.before(a):document.head.append(a)}}}catch(a){console.error("dropin-styles (injectCodeFunction)",a)}})(".cart-cart{container-type:inline-size;container-name:cart}.cart-cart__wrapper{display:grid;grid-template-rows:auto 1fr}.cart-cart__heading{display:grid;row-gap:var(--spacing-small);padding:var(--spacing-medium);padding-bottom:0;font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);color:var(--color-neutral-800)}.cart-cart__heading-divider{width:100%;margin:0}.cart-cart__content{display:grid;grid-template-columns:1fr;padding:0 var(--spacing-medium) var(--spacing-medium)}.cart-cart__empty-cart{justify-self:center;align-self:center;width:100%;max-width:800px}.dropin-price-summary__shipping--zip,.dropin-price-summary__shipping--state{background-color:var(--color-neutral-50)}@container cart (width >= 1024px){.cart-cart__wrapper{grid-template-columns:repeat(var(--grid-3-columns),1fr);grid-column-gap:var(--grid-3-gutters);margin:0 var(--grid-3-margins)}.cart-cart__heading{padding:var(--spacing-small) 0 0 0}.cart-cart__content{padding:var(--spacing-medium) 0}.cart-cart__content .cart-cart-summary-list__heading{padding:0}.cart-cart__heading,.cart-cart__content{grid-column:1 / span 8}.cart-cart__order-summary{grid-row:1 / span 3;grid-column:9 / span 4;height:min-content}.cart-cart__heading--full-width,.cart-cart__content--empty,.cart-cart__content--full-width{grid-column:1 / span 12}}.cart-empty-cart{container-type:inline-size;container-name:cart}.cart-empty-cart__wrapper .dropin-card--secondary{display:grid;grid-auto-rows:min-content;justify-content:center;text-align:center}@container cart (width < 737px){.cart-empty-cart__wrapper .dropin-card{border:unset;border-style:hidden}}.cart-estimate-shipping{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-xsmall);align-items:flex-end;color:var(--color-neutral-800)}.cart-estimate-shipping__label,.cart-estimate-shipping__price{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.cart-estimate-shipping__label--muted{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);color:var(--color-neutral-700)}.cart-estimate-shipping__price--muted{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.cart-estimate-shipping__price{text-align:right}a.cart-estimate-shippingLink{text-decoration:underline}.cart-estimate-shipping__label--bold,.cart-estimate-shipping__price--bold{font:var(--type-body-1-emphasized-font);letter-spacing:var(--type-body-1-emphasized-letter-spacing)}.cart-estimate-shipping__caption{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);grid-column:span 2;color:var(--color-neutral-700)}.cart-estimate-shipping--zip,.cart-estimate-shipping--state{background-color:var(--color-neutral-50)}.cart-estimate-shipping--edit{display:grid;grid-column:1 / span 2;gap:var(--spacing-small);padding-top:var(--spacing-small)}a.cart-estimate-shipping__link{text-decoration:underline}.cart-estimate-shipping--hide{display:none!important}.cart-estimate-shipping--edit button{width:var(--spacing-huge);justify-self:end}.cart-estimate-shipping--loading{opacity:.4;pointer-events:none}.cart-mini-cart{display:flex;flex-direction:column;height:100%;padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium);box-sizing:border-box}.cart-mini-cart__empty-cart{width:100%;max-width:800px;height:100%;display:flex;flex-direction:column;justify-content:center;align-self:center}.cart-mini-cart__heading{display:grid;row-gap:var(--spacing-xsmall);font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing)}.cart-mini-cart__heading-divider{width:100%;margin:var(--spacing-xxsmall) 0 0 0}.cart-mini-cart__products{flex:1;overflow-y:auto;max-height:100%;padding-bottom:var(--spacing-medium)}.cart-mini-cart__products .cart-cart-summary-list__heading{padding:0}.cart-mini-cart__products .dropin-cart-item__configurations li{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.cart-mini-cart__footer{display:grid;grid-auto-flow:row;gap:var(--spacing-small);padding-top:var(--spacing-small);row-gap:var(--spacing-xsmall)}.cart-mini-cart__footer__estimated-total{font:var(--type-body-1-emphasized-font);letter-spacing:var(--type-body-1-emphasized-letter-spacing);display:grid;grid-template:max-content / 1fr auto;gap:var(--spacing-xsmall)}.cart-mini-cart__footer__estimated-total-excluding-taxes{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);display:grid;grid-template:max-content / 1fr auto;gap:var(--spacing-xsmall);color:var(--color-neutral-700)}.cart-mini-cart__footer__ctas{display:grid;grid-auto-flow:row;gap:var(--spacing-xsmall);padding-top:var(--spacing-small)}.cart-cart-summary-grid{container-type:inline-size;container-name:cart-summary-grid;max-width:inherit}.cart-cart-summary-grid__content{display:grid;flex-wrap:wrap;gap:var(--spacing-small);grid-template-columns:repeat(6,1fr);margin:auto}.cart-cart-summary-grid__item-container{aspect-ratio:auto 3/4;display:inline-block}.cart-cart-summary-grid__item-container img{height:auto;max-width:100%}.cart-cart-summary-grid__item-container a:focus{display:block}.cart-cart-summary-grid__content--empty{grid-template-columns:repeat(1,1fr)}.cart-cart-summary-grid__empty-cart{align-self:center;justify-self:center;max-width:800px;width:100%}@container cart-summary-grid (width < 360px){.cart-cart-summary-grid__content{grid-template-columns:repeat(4,1fr);gap:var(--spacing-xsmall)}.cart-cart-summary-grid__content--empty{grid-template-columns:repeat(1,1fr)}}.cart-cart-summary-list{container-type:inline-size;container-name:cart-summary-list}.cart-cart-summary-list__heading{display:grid;row-gap:var(--spacing-xsmall);padding:var(--spacing-medium) 0 0 0;font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);color:var(--color-neutral-800)}.cart-cart-summary-list__heading--full-width{width:100%}.cart-cart-summary-list__heading-divider{width:100%;margin:var(--spacing-xxsmall) 0 var(--spacing-medium) 0}.cart-cart-summary-list__content{display:grid;grid-template-columns:1fr;padding:0}.cart-cart-summary-list__out-of-stock-message{margin:calc(-1 * var(--spacing-xsmall)) 0 var(--spacing-medium) 0}.cart-cart-summary-list__empty-cart{justify-self:center;align-self:center;width:100%;max-width:800px}@container cart-summary-list (width >= 768px){.cart-cart-summary-list__out-of-stock-message{margin:calc(-1 * var(--spacing-small)) 0 var(--spacing-xxbig) 0}}@container cart-summary-list (width >= 1024px){.cart-cart-summary-list__content,.cart-cart-summary-list__heading{grid-column:1 / span 8}.cart-cart-summary-list__heading--full-width,.cart-cart-summary-list__content--empty{grid-column:1 / span 12}.cart-cart-summary-list__content{padding:0}}.cart-order-summary{display:grid;position:relative;grid-auto-flow:row;padding:var(--spacing-medium)}.cart-order-summary__primary{background-color:var(--color-neutral-200)}.cart-order-summary__secondary{background-color:var(--color-neutral-50)}.cart-order-summary__content{display:grid;gap:var(--spacing-xsmall);margin-top:var(--spacing-small)}.cart-order-summary__heading{display:grid;font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing);color:var(--color-neutral-800);gap:var(--spacing-small)}.cart-order-summary__label,.cart-order-summary__price{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.cart-order-summary__label--muted{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);color:var(--color-neutral-700)}.cart-order-summary__price--muted{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.cart-order-summary__price{text-align:right}.cart-order-summary__taxes .dropin-divider:last-child{margin-bottom:0}.cart-order-summary__total{margin-top:var(--spacing-medium)}.cart-order-summary__label--bold,.cart-order-summary__price--bold{font:var(--type-body-1-emphasized-font);letter-spacing:var(--type-body-1-emphasized-letter-spacing)}.cart-order-summary__divider-primary,.cart-order-summary__divider-secondary{width:100%;margin:0}.cart-order-summary__divider-secondary{margin:0}.cart-order-summary__taxEntry.cart-order-summary__entry{margin-top:0}.cart-order-summary__entry,.cart-order-summary__taxEntry{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-xxsmall);align-items:center;color:var(--color-neutral-800)}.cart-order-summary__caption{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);grid-column:span 2;color:var(--color-neutral-700)}.cart-order-summary__primaryAction{margin-top:var(--spacing-small);grid-template-columns:1fr}.cart-order-summary__shipping--edit{display:grid;grid-column:1 / span 2;gap:var(--spacing-small);padding-top:var(--spacing-small);padding-left:var(--spacing-small)}a.cart-order-summary__shippingLink{text-decoration:underline}.cart-order-summary__shipping--hide{display:none!important}.cart-order-summary__shipping--edit button{width:var(--spacing-huge);justify-self:end}.cart-order-summary__shipping--zip,.cart-order-summary__shipping--state{background-color:var(--color-neutral-50)}.cart-order-summary__taxes .dropin-accordion-section__content-container{gap:var(--spacing-small);margin:var(--spacing-small) 0}.cart-order-summary--loading{opacity:.4;pointer-events:none}.cart-order-summary__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0}",{styleId:"Cart"});
|
|
2
|
-
import{jsx as n}from"@dropins/tools/preact-jsx-runtime.js";import{deepmerge as c,Render as
|
|
2
|
+
import{jsx as n}from"@dropins/tools/preact-jsx-runtime.js";import{deepmerge as c,Render as u}from"@dropins/tools/lib.js";import{useState as d,useEffect as p}from"@dropins/tools/preact-hooks.js";import{UIProvider as m}from"@dropins/tools/components.js";import{events as g}from"@dropins/tools/event-bus.js";import"./chunks/resetCart.js";import{c as h}from"./chunks/getStoreConfig.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/persisted-data.js";import"./chunks/CartFragment.js";const f={Cart:{heading:"Shopping Cart ({count})"},MiniCart:{heading:"Shopping Cart ({count})",subtotal:"Subtotal",subtotalExcludingTaxes:"Subtotal excluding taxes",cartLink:"View Cart",checkoutLink:"Checkout"},EmptyCart:{heading:"Your cart is empty",cta:"Start shopping"},PriceSummary:{taxToBeDetermined:"TBD",checkout:"Checkout",orderSummary:"Order Summary",subTotal:{label:"Subtotal",withTaxes:"Including taxes",withoutTaxes:"excluding taxes"},shipping:{label:"Shipping",editZipAction:"Apply",estimated:"Estimated Shipping",estimatedDestination:"Estimated Shipping to ",destinationLinkAriaLabel:"Change destination",zipPlaceholder:"Zip Code",withTaxes:"Including taxes",withoutTaxes:"excluding taxes",alternateField:{zip:"Estimate using country/zip",state:"Estimate using country/state"}},taxes:{total:"Tax Total",totalOnly:"Tax",breakdown:"Taxes",showBreakdown:"Show Tax Breakdown",hideBreakdown:"Hide Tax Breakdown",estimated:"Estimated Tax"},total:{estimated:"Estimated Total",label:"Total",withoutTax:"Total excluding taxes"},estimatedShippingForm:{country:{placeholder:"Country"},state:{placeholder:"State"},zip:{placeholder:"Zip Code"},apply:{label:"Apply"}},freeShipping:"Free"},CartItem:{discountedPrice:"Discounted Price",download:"file",message:"Note",recipient:"To",regularPrice:"Regular Price",sender:"From",file:"{count} file",files:"{count} files",lowInventory:"Only {count} left!",insufficientQuantity:"Only {inventory} of {count} in stock",insufficientQuantityGeneral:"Not enough items for sale",notAvailableMessage:"Requested qty. not available",discountPercentage:"{discount}% off",savingsAmount:"Savings"},EstimateShipping:{label:"Shipping",editZipAction:"Apply",estimated:"Estimated Shipping",estimatedDestination:"Estimated Shipping to ",destinationLinkAriaLabel:"Change destination",zipPlaceholder:"Zip Code",withTaxes:"Including taxes",withoutTaxes:"excluding taxes",alternateField:{zip:"Estimate using country/zip",state:"Estimate using country/state"}},OutOfStockMessage:{heading:"Your cart contains items with limited stock",message:"Please adjust quantities to continue",alert:"Out of stock",action:"Remove all out of stock items from cart"}},x={Cart:f},S={default:x},y=({children:o})=>{var i;const[t,s]=d(),r=(i=h.getConfig())==null?void 0:i.langDefinitions;p(()=>{const e=g.on("locale",a=>{a!==t&&s(a)},{eager:!0});return()=>{e==null||e.off()}},[t]);const l=c(S,r??{});return n(m,{lang:t,langDefinitions:l,children:o})},L=new u(n(y,{}));export{L as render};
|