@dropins/storefront-cart 1.1.0 → 1.2.0
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/applyGiftCardToCart/applyGiftCardToCart.d.ts +4 -0
- package/api/applyGiftCardToCart/graphql/ApplyGiftCardToCartMutation.d.ts +18 -0
- package/api/applyGiftCardToCart/index.d.ts +18 -0
- package/api/fragments.d.ts +1 -0
- package/api/getStoreConfig/graphql/StoreConfigQuery.d.ts +1 -1
- package/api/graphql/GiftFragment.d.ts +5 -0
- package/api/index.d.ts +3 -0
- package/api/removeGiftCardFromCart/graphql/RemoveGiftCardFromCartMutation.d.ts +18 -0
- package/api/removeGiftCardFromCart/index.d.ts +18 -0
- package/api/removeGiftCardFromCart/removeGiftCardFromCart.d.ts +4 -0
- package/api/setGiftOptionsOnCart/graphql/UpdateGiftOptionsMutation.d.ts +18 -0
- package/api/setGiftOptionsOnCart/index.d.ts +18 -0
- package/api/setGiftOptionsOnCart/setGiftOptionsOnCart.d.ts +5 -0
- package/api/updateProductsFromCart/updateProductsFromCart.d.ts +8 -0
- package/api.js +3 -3
- package/chunks/CartSummaryGrid.js +1 -1
- package/chunks/CartSummaryList.js +1 -1
- package/chunks/ChevronUp.js +3 -0
- package/chunks/Coupons.js +3 -0
- package/chunks/EmptyCart.js +1 -1
- package/chunks/GiftCard.js +3 -0
- package/chunks/OrderSummary.js +1 -1
- package/chunks/OrderSummaryLine.js +1 -1
- package/chunks/refreshCart.js +28 -16
- package/chunks/removeGiftCardFromCart.js +31 -0
- package/chunks/setGiftOptionsOnCart.js +20 -0
- package/chunks/updateProductsFromCart.js +4 -4
- package/components/Coupons/Coupons.d.ts +2 -0
- package/components/GiftOptions/Elements/CheckboxGroup.d.ts +20 -0
- package/components/GiftOptions/Elements/FormFields.d.ts +15 -0
- package/components/GiftOptions/Elements/GiftLoader.d.ts +4 -0
- package/components/GiftOptions/Elements/GiftOptionModal.d.ts +14 -0
- package/components/GiftOptions/Elements/ReadOnlyFormView.d.ts +11 -0
- package/components/GiftOptions/Elements/index.d.ts +5 -0
- package/components/GiftOptions/GiftOptions.d.ts +29 -0
- package/components/GiftOptions/index.d.ts +19 -0
- package/components/OrderSummary/OrderSummary.d.ts +27 -0
- package/components/OrderSummaryLine/OrderSummaryLine.d.ts +2 -2
- package/components/index.d.ts +1 -0
- package/containers/CartSummaryGrid.js +1 -1
- package/containers/CartSummaryList.js +1 -1
- package/containers/Coupons.js +1 -1
- package/containers/EmptyCart.js +1 -1
- package/containers/EstimateShipping.js +1 -1
- package/containers/GiftCards/GiftCards.d.ts +7 -0
- package/containers/GiftCards/index.d.ts +19 -0
- package/containers/GiftCards.d.ts +3 -0
- package/containers/GiftCards.js +3 -0
- package/containers/GiftOptions/GiftOptions.d.ts +20 -0
- package/containers/GiftOptions/index.d.ts +19 -0
- package/containers/GiftOptions.d.ts +3 -0
- package/containers/GiftOptions.js +3 -0
- package/containers/MiniCart.js +1 -1
- package/containers/OrderSummary/OrderSummary.d.ts +2 -0
- package/containers/OrderSummary.js +1 -1
- package/containers/OrderSummaryLine/OrderSummaryLine.d.ts +2 -2
- package/containers/OrderSummaryLine.js +1 -1
- package/containers/index.d.ts +2 -0
- package/data/models/cart-model.d.ts +51 -0
- package/data/models/gift-card-account.d.ts +8 -0
- package/data/models/index.d.ts +1 -0
- package/data/models/store-models.d.ts +11 -16
- package/data/transforms/__fixtures__/cartModel.d.ts +14 -0
- package/data/transforms/__fixtures__/productTypesData.d.ts +15 -0
- package/data/transforms/index.d.ts +1 -0
- package/data/transforms/transform-gift-card-account.d.ts +4 -0
- package/fragments.js +130 -5
- package/hooks/index.d.ts +1 -0
- package/hooks/useGiftOptions.d.ts +46 -0
- package/i18n/en_US.json.d.ts +117 -1
- package/lib/giftOptionsHelper.d.ts +18 -0
- package/package.json +1 -1
- package/render.js +2 -2
- package/types/giftOptions.types.d.ts +35 -0
- package/types/index.d.ts +2 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2024 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export declare const APPLY_GIFT_CARD_ON_CART_MUTATION: string;
|
|
18
|
+
//# sourceMappingURL=ApplyGiftCardToCartMutation.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2024 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './applyGiftCardToCart';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
package/api/fragments.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { CART_FRAGMENT } from './graphql/CartFragment';
|
|
2
2
|
export { CART_ITEM_FRAGMENT } from './graphql/CartItemFragment';
|
|
3
3
|
export { DOWNLOADABLE_CART_ITEMS_FRAGMENT } from './graphql/DownloadableCartItemsFragment';
|
|
4
|
+
export { GIFT_MESSAGE_FRAGMENT, GIFT_WRAPPING_FRAGMENT, AVAILABLE_GIFT_WRAPPING_FRAGMENT, APPLIED_GIFT_CARDS_FRAGMENT } from './graphql/GiftFragment';
|
|
4
5
|
//# sourceMappingURL=fragments.d.ts.map
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
-
export declare const STORE_CONFIG_QUERY = "\nquery STORE_CONFIG_QUERY {\n storeConfig {\n minicart_display
|
|
17
|
+
export declare const STORE_CONFIG_QUERY = "\nquery STORE_CONFIG_QUERY {\n storeConfig {\n minicart_display\n minicart_max_items\n cart_expires_in_days\n cart_summary_display_quantity\n max_items_in_order_summary\n default_country\n category_fixed_product_tax_display_setting\n product_fixed_product_tax_display_setting\n sales_fixed_product_tax_display_setting\n shopping_cart_display_full_summary\n shopping_cart_display_grand_total\n shopping_cart_display_price\n shopping_cart_display_shipping\n shopping_cart_display_subtotal\n shopping_cart_display_tax_gift_wrapping\n shopping_cart_display_zero_tax\n configurable_thumbnail_source\n allow_gift_wrapping_on_order\n allow_gift_wrapping_on_order_items\n allow_order\n allow_items\n allow_gift_receipt\n allow_printed_card\n printed_card_priceV2 {\n currency\n value\n }\n cart_gift_wrapping\n cart_printed_card\n }\n}\n";
|
|
18
18
|
//# sourceMappingURL=StoreConfigQuery.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const APPLIED_GIFT_CARDS_FRAGMENT = "\n fragment APPLIED_GIFT_CARDS_FRAGMENT on AppliedGiftCard {\n __typename\n code\n applied_balance {\n value\n currency\n }\n current_balance {\n value\n currency\n }\n expiration_date\n }\n";
|
|
2
|
+
export declare const GIFT_MESSAGE_FRAGMENT = "\n fragment GIFT_MESSAGE_FRAGMENT on GiftMessage {\n __typename\n from\n to\n message\n }\n";
|
|
3
|
+
export declare const GIFT_WRAPPING_FRAGMENT = "\n fragment GIFT_WRAPPING_FRAGMENT on GiftWrapping {\n __typename\n uid\n design\n image {\n url\n }\n price {\n value\n currency\n }\n }\n";
|
|
4
|
+
export declare const AVAILABLE_GIFT_WRAPPING_FRAGMENT = "\n fragment AVAILABLE_GIFT_WRAPPING_FRAGMENT on GiftWrapping {\n __typename\n uid\n design\n image {\n url\n label\n }\n price {\n currency\n value\n }\n }\n";
|
|
5
|
+
//# sourceMappingURL=GiftFragment.d.ts.map
|
package/api/index.d.ts
CHANGED
|
@@ -29,4 +29,7 @@ export * from './refreshCart';
|
|
|
29
29
|
export { getPersistedCartData as getCartDataFromCache } from '../lib/persisted-data';
|
|
30
30
|
export * from './applyCouponsToCart';
|
|
31
31
|
export * from './publishShoppingCartViewEvent';
|
|
32
|
+
export * from './applyGiftCardToCart';
|
|
33
|
+
export * from './removeGiftCardFromCart';
|
|
34
|
+
export * from './setGiftOptionsOnCart';
|
|
32
35
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2024 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export declare const REMOVE_GIFT_CARD_ON_CART_MUTATION: string;
|
|
18
|
+
//# sourceMappingURL=RemoveGiftCardFromCartMutation.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2024 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './removeGiftCardFromCart';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2024 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export declare const SET_GIFT_OPTIONS_ON_CART_MUTATION: string;
|
|
18
|
+
//# sourceMappingURL=UpdateGiftOptionsMutation.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2024 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './setGiftOptionsOnCart';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,6 +3,14 @@ import { CartModel } from '../../data/models';
|
|
|
3
3
|
type UpdateProductsFromCart = Array<{
|
|
4
4
|
uid: string;
|
|
5
5
|
quantity: number;
|
|
6
|
+
giftOptions?: {
|
|
7
|
+
gift_wrapping_id?: string | null;
|
|
8
|
+
gift_message: {
|
|
9
|
+
to: string;
|
|
10
|
+
from: string;
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
6
14
|
}>;
|
|
7
15
|
export declare const updateProductsFromCart: (items: UpdateProductsFromCart) => Promise<CartModel | null>;
|
|
8
16
|
export {};
|
package/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{s as o,f as
|
|
3
|
+
import{s as o,f as m,h as l}from"./chunks/resetCart.js";import{g as $,r as Q,d as H,a as k,b as z,c as V}from"./chunks/resetCart.js";import{C as T,t as f,c as g}from"./chunks/refreshCart.js";import{g as j,b as q,d as B,e as J,i as K,a as W,r as X}from"./chunks/refreshCart.js";import{events as C}from"@dropins/tools/event-bus.js";import{CART_FRAGMENT as h}from"./fragments.js";import{b as A,a as I,c as _}from"./chunks/acdl.js";import{u as Z}from"./chunks/updateProductsFromCart.js";import{g as rt,b as at,a as et}from"./chunks/getEstimateShipping.js";import{g as ot}from"./chunks/getEstimatedTotals.js";import{g as E}from"./chunks/persisted-data.js";import{A as nt,a as ct}from"./chunks/applyCouponsToCart.js";import{a as Ct,r as mt}from"./chunks/removeGiftCardFromCart.js";import{s as ut}from"./chunks/setGiftOptionsOnCart.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const G=`
|
|
4
4
|
mutation ADD_PRODUCTS_TO_CART_MUTATION(
|
|
5
5
|
$cartId: String!,
|
|
6
6
|
$cartItems: [CartItemInput!]!,
|
|
@@ -21,7 +21,7 @@ import{s as o,f as d,h as l}from"./chunks/resetCart.js";import{g as $,r as Q,d a
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
${h}
|
|
24
|
-
`,
|
|
24
|
+
`,y=async a=>{let r=!1;const i=o.cartId||await R().then(s=>(r=!0,s));return m(G,{variables:{cartId:i,cartItems:a.map(({sku:s,parentSku:e,quantity:n,optionsUIDs:t,enteredOptions:c})=>({sku:s,parent_sku:e,quantity:n,selected_options:t,entered_options:c}))}}).then(({errors:s,data:e})=>{var c;const n=[...((c=e==null?void 0:e.addProductsToCart)==null?void 0:c.user_errors)??[],...s??[]];if(n.length>0)return l(n);const t=f(e.addProductsToCart.cart);if(C.emit("cart/updated",t),C.emit("cart/data",t),t){const p=t.items.filter(d=>a.some(({sku:u})=>u===d.topLevelSku));r?A(t,p,o.locale??"en-US"):I(t,p,o.locale??"en-US")}return t})},S=`
|
|
25
25
|
mutation CREATE_GUEST_CART_MUTATION {
|
|
26
26
|
createGuestCart {
|
|
27
27
|
cart {
|
|
@@ -29,4 +29,4 @@ import{s as o,f as d,h as l}from"./chunks/resetCart.js";import{g as $,r as Q,d a
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
`,R=async()=>{const{disableGuestCart:a}=
|
|
32
|
+
`,R=async()=>{const{disableGuestCart:a}=g.getConfig();if(a)throw new Error("Guest cart is disabled");return await m(S).then(({data:r})=>{const i=r.createGuestCart.cart.id;return o.cartId=i,i})},F=()=>{const a=o.locale??"en-US",r=E();r&&_(r,a)};export{nt as ApplyCouponsStrategy,y as addProductsToCart,ct as applyCouponsToCart,Ct as applyGiftCardToCart,g as config,R as createGuestCart,m as fetchGraphQl,j as getCartData,E as getCartDataFromCache,$ as getConfig,rt as getCountries,q as getCustomerCartPayload,at as getEstimateShipping,ot as getEstimatedTotals,B as getGuestCartPayload,et as getRegions,J as getStoreConfig,K as initialize,W as initializeCart,F as publishShoppingCartViewEvent,X as refreshCart,Q as removeFetchGraphQlHeader,mt as removeGiftCardFromCart,H as resetCart,k as setEndpoint,z as setFetchGraphQlHeader,V as setFetchGraphQlHeaders,ut as setGiftOptionsOnCart,Z as updateProductsFromCart};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as
|
|
3
|
+
import{jsx as t,Fragment as l}from"@dropins/tools/preact-jsx-runtime.js";import{useState as y,useEffect as h}from"@dropins/tools/preact-compat.js";import{E as _}from"./EmptyCart.js";import{classes as d,VComponent as C}from"@dropins/tools/lib.js";/* empty css */import{Image as v}from"@dropins/tools/components.js";import"@dropins/tools/preact-hooks.js";import{events as N}from"@dropins/tools/event-bus.js";import{g as b}from"./persisted-data.js";const j=({className:c,children:i,emptyCart:n,products:e,...m})=>t("div",{...m,className:d(["cart-cart-summary-grid",c]),children:t(l,{children:t("div",{className:d(["cart-cart-summary-grid__content",["cart-cart-summary-grid__content--empty",!e]]),children:e||t(C,{node:n,className:"cart-cart-summary-grid__empty-cart"})})})}),D=({children:c,initialData:i=null,routeProduct:n,routeEmptyCartCTA:e,...m})=>{const[s,g]=y(i);h(()=>{const r=N.on("cart/data",a=>{g(a)},{eager:!0});return()=>{r==null||r.off()}},[]);const p=(r,a)=>{const f=r.selectedOptions?`${r.name}: ${Object.entries(r.selectedOptions).join("; ")}`:r.name,o=t(v,{"data-testid":"cart-grid-item-image",loading:a<4?"eager":"lazy",src:r.image.src,alt:r.image.alt,"aria-label":f,width:"100%"});return n?t("div",{className:"cart-cart-summary-grid__item-container",children:t("a",{href:n(r),children:o})},a):o},u=s&&t(l,{children:s.items.map((r,a)=>p(r,a))});return t(j,{...m,emptyCart:t(_,{ctaLinkURL:e?e():void 0}),products:u})};D.getInitialData=async function(){return b()};export{D as C};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as n,jsxs as h,Fragment as X}from"@dropins/tools/preact-jsx-runtime.js";import*as o from"@dropins/tools/preact-compat.js";import{useState as N,useCallback as Ft,useEffect as ot}from"@dropins/tools/preact-compat.js";import{classes as L,VComponent as b,Slot as w}from"@dropins/tools/lib.js";import{E as Mt}from"./EmptyCart.js";/* empty css */import{Divider as st,Skeleton as zt,SkeletonRow as Ut,InLineAlert as qt,Icon as z,CartList as lt,Button as U,Accordion as Tt,AccordionSection as Wt,CartItem as Jt,Price as O,Image as Kt}from"@dropins/tools/components.js";import{g as Rt}from"./persisted-data.js";import{events as Yt}from"@dropins/tools/event-bus.js";import{s as Ht}from"./resetCart.js";import{u as ut}from"./updateProductsFromCart.js";import{S as Dt}from"./ChevronDown.js";import{useText as te}from"@dropins/tools/i18n.js";const ee=d=>o.createElement("svg",{id:"Icon_Chevron_right_Base","data-name":"Icon \\u2013 Chevron right \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...d},o.createElement("g",{id:"Large"},o.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),o.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},o.createElement("path",{vectorEffect:"non-scaling-stroke",id:"chevron",d:"M199.75,367.5l4.255,-4.255-4.255,-4.255",transform:"translate(-189.25 -351.0)",fill:"none",stroke:"currentColor"})))),dt=d=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d},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)"})))),ne=d=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d},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"})),gt=({className:d,children:q,heading:k,footer:y,emptyCart:_,products:u,outOfStockMessage:v,variant:S="primary",loading:m=!0,...c})=>n("div",{...c,className:L(["cart-cart-summary-list",d,`cart-cart-summary-list__background--${S}`]),children:m?n(re,{}):h(X,{children:[(k||v)&&h("div",{"data-testid":"cart-summary-list-heading-wrapper",className:L(["cart-cart-summary-list__heading",["cart-cart-summary-list__heading--full-width",!u]]),children:[k&&h(X,{children:[n(b,{node:k,className:"cart-cart-summary-list__heading-text"}),n(st,{variant:"primary",className:L(["cart-cart-summary-list__heading-divider"])})]}),v&&n(b,{node:v,className:"cart-cart-summary-list__out-of-stock-message"})]}),n("div",{className:L(["cart-cart-summary-list__content",["cart-cart-summary-list__content--empty",!u]]),children:u||n(b,{node:_,className:"cart-cart-summary-list__empty-cart"})}),y&&h(X,{children:[n(st,{variant:"primary",className:L(["cart-cart-summary-list__footer-divider"])}),n(b,{node:y,className:"cart-cart-summary-list__footer-text"})]})]})}),re=()=>n(zt,{"data-testid":"cart-summary-list-skeleton",className:"cart-cart-summary-list__skeleton",rowGap:"medium",children:n(Ut,{variant:"row",size:"xlarge",fullWidth:!0,lines:3,multilineGap:"small"})}),ae=({initialData:d=null,hideHeading:q,hideFooter:k,routeProduct:y,routeEmptyCartCTA:_,routeCart:u,onItemUpdate:v,onItemRemove:S,maxItems:m,slots:c,attributesToHide:l=[],enableRemoveItem:j,enableUpdateItemQuantity:T,onItemsErrorsChange:$,accordion:ft=!1,variant:Z="primary",isLoading:mt,showMaxItems:W,showDiscount:ht,showSavings:yt,quantityType:vt,dropdownOptions:pt,...J})=>{var rt;const[B,kt]=N(!d),[a,Ct]=N(d),[E,wt]=N(new Set),[A,Lt]=N(new Map),s=(rt=Ht.config)==null?void 0:rt.shoppingCartDisplaySetting,[Q,_t]=N(W?!0:!m&&!W),i=te({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",viewMore:"Cart.Cart.viewMore",viewAll:"Cart.Cart.viewAll",discountPercent:"Cart.CartItem.discountPercentage",savingsAmount:"Cart.CartItem.savingsAmount"}),F=(t,e)=>{wt(r=>(e?r.add(t):r.delete(t),new Set(r)))},K=(t,e)=>{Lt(r=>(e?r.set(t,e):r.delete(t),new Map(r)))},M=(t,e)=>{F(t.uid,!0),K(t.uid),j&&e===0?ut([{uid:t.uid,quantity:e}]).then(()=>{S==null||S({item:t})}).finally(()=>{F(t.uid,!1)}).catch(r=>{console.warn(r)}):T&&ut([{uid:t.uid,quantity:e}]).then(()=>{v==null||v({item:t})}).finally(()=>{F(t.uid,!1)}).catch(r=>{console.warn(r),K(t.uid,r.message)})},St=Ft(()=>{_t(t=>!t)},[]);ot(()=>{const t=Yt.on("cart/data",e=>{Ct(e),kt(!!mt)},{eager:!0});return()=>{t==null||t.off()}},[]),ot(()=>{$&&$(A)},[A,$]);const Et=(t,e)=>{if(l.includes("image"))return;const r=n(Kt,{"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 n(w,{name:"Thumbnail",slot:c==null?void 0:c.Thumbnail,context:{item:t},children:y?n("a",{href:y(t),children:r}):r})},It=t=>{if(!l.includes("name"))return n("span",{"data-testid":"cart-list-item-title",children:y?n("a",{href:y(t),children:t.name}):t.name})},xt=t=>{if(l.includes("configurations"))return;const e={...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(e).length!==0)return e},Pt=t=>{var e,r,f,g;return(s==null?void 0:s.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:(r=t.taxedPrice)==null?void 0:r.currency,style:{font:"inherit"},"data-testid":"including-tax-item-price"}:{amount:(f=t.regularPrice)==null?void 0:f.value,currency:(g=t.regularPrice)==null?void 0:g.currency,style:{font:"inherit"},"data-testid":"regular-item-price"}},Nt=t=>{var e,r;return{amount:(e=t.savingsAmount)==null?void 0:e.value,currency:(r=t.savingsAmount)==null?void 0:r.currency,style:{font:"inherit"},"data-testid":"item-savings-amount"}},Ot=t=>(s==null?void 0:s.price)==="INCLUDING_EXCLUDING_TAX"?n(O,{amount:t.rowTotal.value,currency:t.rowTotal.currency,"data-testid":"excluding-tax-total","aria-label":i.regularPrice}):void 0,At=t=>{var f,g,p,C,I,x,P,at,it,ct;const e={"aria-label":i.regularPrice},r=t.discounted?{}:null;return["INCLUDING_TAX","INCLUDING_EXCLUDING_TAX"].includes(s==null?void 0:s.price)?(e.amount=(f=t.rowTotalIncludingTax)==null?void 0:f.value,e.currency=(g=t.rowTotalIncludingTax)==null?void 0:g.currency,e.variant=t.discounted?"strikethrough":"default",e["data-testid"]="including-tax-item-total",r&&(e.amount=(p=t.total)==null?void 0:p.value,e.currency=(C=t.total)==null?void 0:C.currency,r.amount=(I=t.rowTotalIncludingTax)==null?void 0:I.value,r.currency=(x=t.rowTotalIncludingTax)==null?void 0:x.currency,r.sale=!0,r["aria-label"]=i.discountedPrice,r["data-testid"]="discount-total")):(e.amount=(P=t.total)==null?void 0:P.value,e.currency=(at=t.total)==null?void 0:at.currency,e.variant=t.discounted?"strikethrough":"default",e["data-testid"]="regular-item-total",r&&(r.amount=(it=t.discountedTotal)==null?void 0:it.value,r.currency=(ct=t.discountedTotal)==null?void 0:ct.currency,r.sale=!0,r["aria-label"]=i.regularPrice,r["data-testid"]="discount-total")),{totalProps:e,discountProps:r}},Qt=t=>{var I,x,P;if(l.includes("warning"))return;const e=A.get(t.uid),r=(I=A.get(t.uid))==null?void 0:I.includes("The requested qty is not available"),f=E.has(t.uid),g=t.insufficientQuantity&&t.stockLevel?t.stockLevel==="noNumber"?i.insufficientQuantityGeneral:i.insufficientQuantity.replace("{inventory}",(x=t.stockLevel)==null?void 0:x.toString()).replace("{count}",t.quantity.toString()):"",p=t.lowInventory&&t.onlyXLeftInStock&&i.lowInventory.replace("{count}",(P=t.onlyXLeftInStock)==null?void 0:P.toString()),C=!t.outOfStock&&e&&r?i.notAvailableMessage:e;return!f&&(e||t.insufficientQuantity||t.lowInventory)?h("span",{"data-testid":"item-warning",children:[n(z,{source:ne,size:"16"}),C||g||p]}):void 0},Gt=t=>l!=null&&l.includes("alert")?void 0:!E.has(t.uid)&&t.outOfStock?h("span",{"data-testid":"item-alert",children:[n(z,{source:dt,size:"16"}),i.outOfStockAlert]}):void 0,Vt=t=>n(w,{name:"ProductAttributes",slot:c==null?void 0:c.ProductAttributes,context:{item:t}}),bt=t=>{if(!l.includes("sku"))return n("span",{"data-testid":"cart-list-item-sku",children:t.sku})},Xt=t=>n(w,{name:"Footer",slot:c==null?void 0:c.Footer,context:{item:t}}),R=t=>a!=null&&a.totalQuantity?a.items.filter(t).map((e,r)=>{var p;const{totalProps:f,discountProps:g}=At(e);return n(Jt,{updating:E==null?void 0:E.has(e.uid),loading:B,"data-testid":`cart-list-item-entry-${e.uid}`,image:Et(e,r),title:It(e),sku:bt(e),price:l.includes("price")?void 0:n(O,{...Pt(e)}),quantity:l.includes("quantity")?void 0:e.quantity,total:h(X,{children:[l.includes("total")?void 0:n(O,{...f}),l.includes("totalDiscount")?void 0:g&&n(O,{...g})]}),attributes:Vt(e),configurations:xt(e),totalExcludingTax:l.includes("totalExcludingTax")?void 0:Ot(e),taxIncluded:(s==null?void 0:s.price)==="INCLUDING_TAX",taxExcluded:!l.includes("totalExcludingTax")&&(s==null?void 0:s.price)==="INCLUDING_EXCLUDING_TAX",warning:Qt(e),alert:Gt(e),quantityType:vt,dropdownOptions:pt,onQuantity:T?C=>{M(e,C)}:void 0,onRemove:j?()=>M(e,0):void 0,discount:ht&&e.discounted&&e.discountPercentage?n("div",{"data-testid":"item-discount-percent",children:i.discountPercent.replace("{discount}",((p=e.discountPercentage)==null?void 0:p.toString())??"")}):void 0,savings:yt&&e.discounted&&e.savingsAmount?h("div",{children:[n("span",{children:n(O,{...Nt(e)})})," ",i.savingsAmount]}):void 0,footer:Xt(e)},e.uid)}):null,Y=n(w,{name:"EmptyCart",slot:c==null?void 0:c.EmptyCart,context:{},children:n(Mt,{"data-testid":"empty-cart",ctaLinkURL:_==null?void 0:_()})}),H=n(w,{name:"Heading",slot:c==null?void 0:c.Heading,context:{count:a==null?void 0:a.totalQuantity},children:n("div",{"data-testid":"default-cart-heading",children:i.heading.replace("({count})",a!=null&&a.totalQuantity?`(${a==null?void 0:a.totalQuantity.toString()})`:"")})}),jt=H.props.children.props.children,$t=()=>{const t=a==null?void 0:a.items.filter(e=>e.outOfStock);t==null||t.forEach(e=>{M(e,0)})},Zt=R(t=>t.outOfStock||t.insufficientQuantity||!1),D=a!=null&&a.hasOutOfStockItems?n(qt,{"data-testid":"cart-out-of-stock-message",icon:n(z,{source:dt,size:"16"}),itemList:n(lt,{"data-testid":"out-of-stock-cart-items",children:Zt}),type:"warning",heading:i.outOfStockHeading,description:i.outOfStockDescription,variant:"primary",actionButtonPosition:"bottom",additionalActions:a!=null&&a.hasFullyOutOfStockItems&&j?[{label:i.removeAction,onClick:$t}]:void 0}):void 0,G=R(t=>!t.outOfStock&&!t.insufficientQuantity),tt=Q?Math.max(m||5,5):Math.min((a==null?void 0:a.totalQuantity)||5,5),et=(a==null?void 0:a.totalQuantity)>tt,Bt=et&&!Q&&tt!=m,V=a!=null&&a.totalQuantity&&G?n(w,{name:"Footer",slot:c==null?void 0:c.CartSummaryFooter,context:{displayMaxItems:Q,routeCart:u},"data-testid":"cart-cart-summary-footer-slot",children:n("div",{"data-testid":"cart-cart-summary-footer",children:et?Bt?n(U,{className:"cart-cart-summary-list-footer__action",onClick:St,"data-testid":"view-more-items-button",variant:"tertiary",children:i.viewMore}):u&&n(U,{className:"cart-cart-summary-list-footer__action",href:u(),variant:"tertiary","data-testid":"view-cart-or-less-items-button",children:i.viewAll}):u&&n(U,{className:"cart-cart-summary-list-footer__action",href:u(),variant:"tertiary","data-testid":"view-cart-button",children:i.viewAll})})}):null,nt=a!=null&&a.totalQuantity?n(lt,{"data-testid":"cart-list",children:G==null?void 0:G.slice(0,Q?Math.max(m||(a==null?void 0:a.totalQuantity),5):Math.min(m??5,5))}):null;return ft?n(Tt,{"data-testid":"cart-summary-list-accordion",className:L(["cart-cart-summary-list-accordion",`cart-cart-summary-list__background--${Z}`]),iconOpen:ee,iconClose:Dt,children:n(Wt,{title:jt,"data-testid":"cart-summary-list-accordion__section",open:!0,renderContentWhenClosed:!0,children:n(gt,{...J,"aria-expanded":!0,"aria-label":"TEST",className:"cart-cart-summary-list-accordion__list",loading:B,footer:k?void 0:V||(u?V:void 0),emptyCart:Y,products:nt,outOfStockMessage:D,variant:Z})})}):n(gt,{...J,heading:q?void 0:H,footer:k?void 0:V||(u?V:void 0),loading:B,emptyCart:Y,products:nt,outOfStockMessage:D,variant:Z})};ae.getInitialData=async function(){return Rt()};export{ae as C};
|
|
3
|
+
import{jsx as n,jsxs as y,Fragment as j}from"@dropins/tools/preact-jsx-runtime.js";import*as o from"@dropins/tools/preact-compat.js";import{useState as N,useCallback as Ft,useEffect as ot}from"@dropins/tools/preact-compat.js";import{classes as L,VComponent as X,Slot as w}from"@dropins/tools/lib.js";import{E as Mt}from"./EmptyCart.js";/* empty css */import{Divider as st,Skeleton as zt,SkeletonRow as qt,InLineAlert as Tt,Icon as q,CartList as lt,Button as T,Accordion as Ut,AccordionSection as Wt,CartItem as Jt,Price as O,Image as Kt}from"@dropins/tools/components.js";import"@dropins/tools/preact-hooks.js";import{g as Rt}from"./persisted-data.js";import{events as Yt}from"@dropins/tools/event-bus.js";import{s as Ht}from"./resetCart.js";import{u as ut}from"./updateProductsFromCart.js";import{S as Dt}from"./ChevronDown.js";import{useText as te}from"@dropins/tools/i18n.js";const ee=d=>o.createElement("svg",{id:"Icon_Chevron_right_Base","data-name":"Icon \\u2013 Chevron right \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...d},o.createElement("g",{id:"Large"},o.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),o.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},o.createElement("path",{vectorEffect:"non-scaling-stroke",id:"chevron",d:"M199.75,367.5l4.255,-4.255-4.255,-4.255",transform:"translate(-189.25 -351.0)",fill:"none",stroke:"currentColor"})))),dt=d=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d},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)"})))),ne=d=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d},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"})),gt=({className:d,children:U,heading:k,footer:v,emptyCart:_,products:u,outOfStockMessage:m,variant:S="primary",loading:h=!0,...c})=>n("div",{...c,className:L(["cart-cart-summary-list",d,`cart-cart-summary-list__background--${S}`]),children:h?n(re,{}):y(j,{children:[(k||m)&&y("div",{"data-testid":"cart-summary-list-heading-wrapper",className:L(["cart-cart-summary-list__heading",["cart-cart-summary-list__heading--full-width",!u]]),children:[k&&y(j,{children:[n(X,{node:k,className:"cart-cart-summary-list__heading-text"}),n(st,{variant:"primary",className:L(["cart-cart-summary-list__heading-divider"])})]}),m&&n(X,{node:m,className:"cart-cart-summary-list__out-of-stock-message"})]}),n("div",{className:L(["cart-cart-summary-list__content",["cart-cart-summary-list__content--empty",!u]]),children:u||n(X,{node:_,className:"cart-cart-summary-list__empty-cart"})}),v&&y(j,{children:[n(st,{variant:"primary",className:L(["cart-cart-summary-list__footer-divider"])}),n(X,{node:v,className:"cart-cart-summary-list__footer-text"})]})]})}),re=()=>n(zt,{"data-testid":"cart-summary-list-skeleton",className:"cart-cart-summary-list__skeleton",rowGap:"medium",children:n(qt,{variant:"row",size:"xlarge",fullWidth:!0,lines:3,multilineGap:"small"})}),ae=({initialData:d=null,hideHeading:U,hideFooter:k,routeProduct:v,routeEmptyCartCTA:_,routeCart:u,onItemUpdate:m,onItemRemove:S,maxItems:h,slots:c,attributesToHide:l=[],enableRemoveItem:$,enableUpdateItemQuantity:W,onItemsErrorsChange:Z,accordion:ft=!1,variant:B="primary",isLoading:mt,showMaxItems:J,showDiscount:ht,showSavings:yt,quantityType:vt,dropdownOptions:pt,...K})=>{var rt;const[F,kt]=N(!d),[a,Ct]=N(d),[E,wt]=N(new Set),[A,Lt]=N(new Map),s=(rt=Ht.config)==null?void 0:rt.shoppingCartDisplaySetting,[Q,_t]=N(J?!0:!h&&!J),i=te({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",viewMore:"Cart.Cart.viewMore",viewAll:"Cart.Cart.viewAll",discountPercent:"Cart.CartItem.discountPercentage",savingsAmount:"Cart.CartItem.savingsAmount"}),G=(t,e)=>{wt(r=>(e?r.add(t):r.delete(t),new Set(r)))},M=(t,e)=>{Lt(r=>(e?r.set(t,e):r.delete(t),new Map(r)))},z=(t,e)=>{G(t.uid,!0),M(t.uid),$&&e===0?ut([{uid:t.uid,quantity:e}]).then(()=>{S==null||S({item:t})}).finally(()=>{G(t.uid,!1)}).catch(r=>{console.warn(r)}):W&&ut([{uid:t.uid,quantity:e}]).then(()=>{m==null||m({item:t})}).finally(()=>{G(t.uid,!1)}).catch(r=>{console.warn(r),M(t.uid,r.message)})},St=Ft(()=>{_t(t=>!t)},[]);ot(()=>{const t=Yt.on("cart/data",e=>{Ct(e),kt(!!mt)},{eager:!0});return()=>{t==null||t.off()}},[]),ot(()=>{Z&&Z(A)},[A,Z]);const Et=(t,e)=>{if(l.includes("image"))return;const r=n(Kt,{"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 n(w,{name:"Thumbnail",slot:c==null?void 0:c.Thumbnail,context:{item:t},children:v?n("a",{href:v(t),children:r}):r})},It=t=>{if(!l.includes("name"))return n("span",{"data-testid":"cart-list-item-title",children:v?n("a",{href:v(t),children:t.name}):t.name})},xt=t=>{if(l.includes("configurations"))return;const e={...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(e).length!==0)return e},Pt=t=>{var e,r,f,g;return(s==null?void 0:s.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:(r=t.taxedPrice)==null?void 0:r.currency,style:{font:"inherit"},"data-testid":"including-tax-item-price"}:{amount:(f=t.regularPrice)==null?void 0:f.value,currency:(g=t.regularPrice)==null?void 0:g.currency,style:{font:"inherit"},"data-testid":"regular-item-price"}},Nt=t=>{var e,r;return{amount:(e=t.savingsAmount)==null?void 0:e.value,currency:(r=t.savingsAmount)==null?void 0:r.currency,style:{font:"inherit"},"data-testid":"item-savings-amount"}},Ot=t=>(s==null?void 0:s.price)==="INCLUDING_EXCLUDING_TAX"?n(O,{amount:t.rowTotal.value,currency:t.rowTotal.currency,"data-testid":"excluding-tax-total","aria-label":i.regularPrice}):void 0,At=t=>{var f,g,p,C,I,x,P,at,it,ct;const e={"aria-label":i.regularPrice},r=t.discounted?{}:null;return["INCLUDING_TAX","INCLUDING_EXCLUDING_TAX"].includes(s==null?void 0:s.price)?(e.amount=(f=t.rowTotalIncludingTax)==null?void 0:f.value,e.currency=(g=t.rowTotalIncludingTax)==null?void 0:g.currency,e.variant=t.discounted?"strikethrough":"default",e["data-testid"]="including-tax-item-total",r&&(e.amount=(p=t.total)==null?void 0:p.value,e.currency=(C=t.total)==null?void 0:C.currency,r.amount=(I=t.rowTotalIncludingTax)==null?void 0:I.value,r.currency=(x=t.rowTotalIncludingTax)==null?void 0:x.currency,r.sale=!0,r["aria-label"]=i.discountedPrice,r["data-testid"]="discount-total")):(e.amount=(P=t.total)==null?void 0:P.value,e.currency=(at=t.total)==null?void 0:at.currency,e.variant=t.discounted?"strikethrough":"default",e["data-testid"]="regular-item-total",r&&(r.amount=(it=t.discountedTotal)==null?void 0:it.value,r.currency=(ct=t.discountedTotal)==null?void 0:ct.currency,r.sale=!0,r["aria-label"]=i.regularPrice,r["data-testid"]="discount-total")),{totalProps:e,discountProps:r}},Qt=t=>{var I,x,P;if(l.includes("warning"))return;const e=A.get(t.uid),r=(I=A.get(t.uid))==null?void 0:I.includes("The requested qty is not available"),f=E.has(t.uid),g=t.insufficientQuantity&&t.stockLevel?t.stockLevel==="noNumber"?i.insufficientQuantityGeneral:i.insufficientQuantity.replace("{inventory}",(x=t.stockLevel)==null?void 0:x.toString()).replace("{count}",t.quantity.toString()):"",p=t.lowInventory&&t.onlyXLeftInStock&&i.lowInventory.replace("{count}",(P=t.onlyXLeftInStock)==null?void 0:P.toString()),C=!t.outOfStock&&e&&r?i.notAvailableMessage:e;return!f&&(e||t.insufficientQuantity||t.lowInventory)?y("span",{"data-testid":"item-warning",children:[n(q,{source:ne,size:"16"}),C||g||p]}):void 0},Gt=t=>l!=null&&l.includes("alert")?void 0:!E.has(t.uid)&&t.outOfStock?y("span",{"data-testid":"item-alert",children:[n(q,{source:dt,size:"16"}),i.outOfStockAlert]}):void 0,Vt=t=>n(w,{name:"ProductAttributes",slot:c==null?void 0:c.ProductAttributes,context:{item:t}}),bt=t=>{if(!l.includes("sku"))return n("span",{"data-testid":"cart-list-item-sku",children:t.sku})},Xt=t=>n(w,{name:"Footer",slot:c==null?void 0:c.Footer,context:{item:t,handleItemsLoading:G,handleItemsError:M,onItemUpdate:m}}),R=t=>a!=null&&a.totalQuantity?a.items.filter(t).map((e,r)=>{var p;const{totalProps:f,discountProps:g}=At(e);return n(Jt,{updating:E==null?void 0:E.has(e.uid),loading:F,"data-testid":`cart-list-item-entry-${e.uid}`,image:Et(e,r),title:It(e),sku:bt(e),price:l.includes("price")?void 0:n(O,{...Pt(e)}),quantity:l.includes("quantity")?void 0:e.quantity,total:y(j,{children:[l.includes("total")?void 0:n(O,{...f}),l.includes("totalDiscount")?void 0:g&&n(O,{...g})]}),attributes:Vt(e),configurations:xt(e),totalExcludingTax:l.includes("totalExcludingTax")?void 0:Ot(e),taxIncluded:(s==null?void 0:s.price)==="INCLUDING_TAX",taxExcluded:!l.includes("totalExcludingTax")&&(s==null?void 0:s.price)==="INCLUDING_EXCLUDING_TAX",warning:Qt(e),alert:Gt(e),quantityType:vt,dropdownOptions:pt,onQuantity:W?C=>{z(e,C)}:void 0,onRemove:$?()=>z(e,0):void 0,discount:ht&&e.discounted&&e.discountPercentage?n("div",{"data-testid":"item-discount-percent",children:i.discountPercent.replace("{discount}",((p=e.discountPercentage)==null?void 0:p.toString())??"")}):void 0,savings:yt&&e.discounted&&e.savingsAmount?y("div",{children:[n("span",{children:n(O,{...Nt(e)})})," ",i.savingsAmount]}):void 0,footer:Xt(e)},e.uid)}):null,Y=n(w,{name:"EmptyCart",slot:c==null?void 0:c.EmptyCart,context:{},children:n(Mt,{"data-testid":"empty-cart",ctaLinkURL:_==null?void 0:_()})}),H=n(w,{name:"Heading",slot:c==null?void 0:c.Heading,context:{count:a==null?void 0:a.totalQuantity},children:n("div",{"data-testid":"default-cart-heading",children:i.heading.replace("({count})",a!=null&&a.totalQuantity?`(${a==null?void 0:a.totalQuantity.toString()})`:"")})}),jt=H.props.children.props.children,$t=()=>{const t=a==null?void 0:a.items.filter(e=>e.outOfStock);t==null||t.forEach(e=>{z(e,0)})},Zt=R(t=>t.outOfStock||t.insufficientQuantity||!1),D=a!=null&&a.hasOutOfStockItems?n(Tt,{"data-testid":"cart-out-of-stock-message",icon:n(q,{source:dt,size:"16"}),itemList:n(lt,{"data-testid":"out-of-stock-cart-items",children:Zt}),type:"warning",heading:i.outOfStockHeading,description:i.outOfStockDescription,variant:"primary",actionButtonPosition:"bottom",additionalActions:a!=null&&a.hasFullyOutOfStockItems&&$?[{label:i.removeAction,onClick:$t}]:void 0}):void 0,V=R(t=>!t.outOfStock&&!t.insufficientQuantity),tt=Q?Math.max(h||5,5):Math.min((a==null?void 0:a.totalQuantity)||5,5),et=(a==null?void 0:a.totalQuantity)>tt,Bt=et&&!Q&&tt!=h,b=a!=null&&a.totalQuantity&&V?n(w,{name:"Footer",slot:c==null?void 0:c.CartSummaryFooter,context:{displayMaxItems:Q,routeCart:u},"data-testid":"cart-cart-summary-footer-slot",children:n("div",{"data-testid":"cart-cart-summary-footer",children:et?Bt?n(T,{className:"cart-cart-summary-list-footer__action",onClick:St,"data-testid":"view-more-items-button",variant:"tertiary",children:i.viewMore}):u&&n(T,{className:"cart-cart-summary-list-footer__action",href:u(),variant:"tertiary","data-testid":"view-cart-or-less-items-button",children:i.viewAll}):u&&n(T,{className:"cart-cart-summary-list-footer__action",href:u(),variant:"tertiary","data-testid":"view-cart-button",children:i.viewAll})})}):null,nt=a!=null&&a.totalQuantity?n(lt,{"data-testid":"cart-list",children:V==null?void 0:V.slice(0,Q?Math.max(h||(a==null?void 0:a.totalQuantity),5):Math.min(h??5,5))}):null;return ft?n(Ut,{"data-testid":"cart-summary-list-accordion",className:L(["cart-cart-summary-list-accordion",`cart-cart-summary-list__background--${B}`]),iconOpen:ee,iconClose:Dt,children:n(Wt,{title:jt,"data-testid":"cart-summary-list-accordion__section",open:!0,renderContentWhenClosed:!0,children:n(gt,{...K,"aria-expanded":!0,"aria-label":"TEST",className:"cart-cart-summary-list-accordion__list",loading:F,footer:k?void 0:b||(u?b:void 0),emptyCart:Y,products:nt,outOfStockMessage:D,variant:B})})}):n(gt,{...K,heading:U?void 0:H,footer:k?void 0:b||(u?b:void 0),loading:F,emptyCart:Y,products:nt,outOfStockMessage:D,variant:B})};ae.getInitialData=async function(){return Rt()};export{ae as C};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import*as e from"@dropins/tools/preact-compat.js";const o=t=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{d:"M7.74512 14.132L12.0001 9.87701L16.2551 14.132",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"}));export{o as S};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import*as e from"@dropins/tools/preact-compat.js";import{useRef as k}from"@dropins/tools/preact-compat.js";import{jsx as n,jsxs as u}from"@dropins/tools/preact-jsx-runtime.js";import{classes as t,VComponent as r,getFormValues as x}from"@dropins/tools/lib.js";import{Accordion as L,AccordionSection as S}from"@dropins/tools/components.js";/* empty css */import{S as C}from"./Coupon.js";import{useText as N}from"@dropins/tools/i18n.js";const B=o=>e.createElement("svg",{id:"Icon_Add_Base","data-name":"Icon \\u2013 Add \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...o},e.createElement("g",{id:"Large"},e.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),e.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},e.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_579","data-name":"Line 579",y2:12.7,transform:"translate(2.216 -4.087)",fill:"none",stroke:"currentColor"}),e.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_580","data-name":"Line 580",x2:12.7,transform:"translate(-4.079 2.263)",fill:"none",stroke:"currentColor"})))),V=o=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o},e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 5.64001L5.62988 18.37",stroke:"currentColor"}),e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 18.37L5.62988 5.64001",stroke:"currentColor"})),I=o=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o},e.createElement("path",{d:"M17.3332 11.75H6.6665",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke",fill:"none",stroke:"currentColor"})),W=({accordionSectionTitle:o,accordionSectionIcon:h,className:g,children:M,couponCodeField:s,applyCouponsButton:i,appliedCoupons:l,error:d,onApplyCoupon:a,...p})=>{const c=k(null),v=N({couponTitle:"Cart.PriceSummary.coupon.title"}),w=_=>{var f;_.preventDefault();const E=x(c.current);a==null||a(E);const m=(f=c==null?void 0:c.current)==null?void 0:f.querySelector("input");m&&(m.value="")};return n("div",{...p,"data-testid":"cart-coupons",className:t(["cart-coupons",g]),children:n(L,{"data-testid":"coupon-code",className:t(["cart-coupons__accordion"]),actionIconPosition:"right",iconOpen:B,iconClose:I,children:u(S,{title:o??v.couponTitle,iconLeft:h??C,showIconLeft:!0,renderContentWhenClosed:!1,"data-testid":"coupon-code-accordion-section",className:t(["cart-coupons__accordion-section"]),children:[n("form",{"data-testid":"coupon-code-form",className:t(["coupon-code-form--edit"]),ref:c,children:u("div",{className:t(["coupon-code-form__action"]),children:[s&&n(r,{node:s,className:t(["coupon-code-form__codes"])}),i&&n(r,{node:i,className:t(["coupon-code-form--button"]),onClick:w,type:"submit"})]})}),d&&n(r,{node:d,className:t(["coupon-code-form__error"])}),l&&n(r,{node:l,className:t(["coupon-code-form__applied"])})]})})})};export{W as C,V as S};
|
package/chunks/EmptyCart.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
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
|
|
3
|
+
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};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import*as e from"@dropins/tools/preact-compat.js";const C=t=>e.createElement("svg",{width:24,height:16,viewBox:"0 0 24 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{d:"M22.5364 9.8598V2.1658C22.5364 1.63583 22.099 1.20996 21.576 1.20996H2.42337C1.89083 1.20996 1.46289 1.64529 1.46289 2.1658V9.8598M22.5364 9.8598H1.46289M22.5364 9.8598V13.844C22.5364 14.3645 22.1085 14.7999 21.576 14.7999H2.42337C1.90034 14.7999 1.46289 14.374 1.46289 13.844V9.8598M3.9164 12.5191L7.5396 9.8598M7.5396 9.8598L11.1628 12.5191M7.5396 9.8598C7.5396 9.8598 6.96902 7.26674 6.40795 6.70838C5.84687 6.15002 4.93394 6.15002 4.37287 6.70838C3.81179 7.26674 3.81179 8.17526 4.37287 8.73362C4.93394 9.29198 7.5396 9.8598 7.5396 9.8598ZM7.5396 9.8598C7.5396 9.8598 10.1643 9.27305 10.7254 8.71469C11.2864 8.15633 11.2864 7.24782 10.7254 6.68946C10.1643 6.1311 9.25135 6.1311 8.69028 6.68946C8.12921 7.24782 7.5396 9.8598 7.5396 9.8598ZM7.5396 14.7904V1.20996",stroke:"currentColor",strokeLinecap:"round"}));export{C as S};
|
package/chunks/OrderSummary.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsxs as E,jsx as r,Fragment as We}from"@dropins/tools/preact-jsx-runtime.js";import*as Ie from"@dropins/tools/preact-compat.js";import{useState as M,useEffect as ae,useCallback as Fe}from"@dropins/tools/preact-compat.js";import{VComponent as B,classes as ke,Slot as we}from"@dropins/tools/lib.js";import{events as Ee}from"@dropins/tools/event-bus.js";import{g as Ge}from"./persisted-data.js";import{s as Oe}from"./resetCart.js";import{g as ze}from"./getEstimatedTotals.js";import{p as Ve}from"./acdl.js";import{Accordion as Ne,AccordionSection as Le,ProgressSpinner as Ze,Divider as je,Price as l,Icon as Ue,Button as Qe}from"@dropins/tools/components.js";/* empty css */import{O as v}from"./OrderSummaryLine.js";import{S as De}from"./ChevronDown.js";import{useText as Ae}from"@dropins/tools/i18n.js";import{S as Xe}from"./Coupon.js";const Be=O=>Ie.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...O},Ie.createElement("path",{d:"M7.74512 14.132L12.0001 9.87701L16.2551 14.132",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),$e=({className:O,children:A,variant:P="primary",heading:s,loading:N=!0,subTotal:g,shipping:m,discounts:_,taxTotal:x,taxesApplied:e,total:p,primaryAction:L,coupons:o,totalSaved:y,updateLineItems:I=T=>T,...t})=>{const[T,D]=M(!1),i=Ae({checkout:"Cart.PriceSummary.checkout",discountedPrice:"Cart.CartItem.discountedPrice",download:"Cart.CartItem.download",heading:"Cart.Cart.heading",message:"Cart.CartItem.message",regularPrice:"Cart.CartItem.regularPrice",recipient:"Cart.CartItem.recipient",sender:"Cart.CartItem.sender",file:"Cart.CartItem.file",files:"Cart.CartItem.files",orderSummary:"Cart.PriceSummary.orderSummary",taxesBreakdownTitle:"Cart.PriceSummary.taxes.breakdown",taxTotal:"Cart.PriceSummary.taxes.total",taxEstimated:"Cart.PriceSummary.taxes.estimated",taxTotalOnly:"Cart.PriceSummary.taxes.totalOnly",showTaxBreakdown:"Cart.PriceSummary.taxes.showBreakdown",hideTaxBreakdown:"Cart.PriceSummary.taxes.hideBreakdown",taxToBeDetermined:"Cart.PriceSummary.taxToBeDetermined",subtotalLabel:"Cart.PriceSummary.subTotal.label",subtotalWithTaxes:"Cart.PriceSummary.subTotal.withTaxes",subtotalWithoutTaxes:"Cart.PriceSummary.subTotal.withoutTaxes",totalEstimated:"Cart.PriceSummary.total.estimated",totalLabel:"Cart.PriceSummary.total.label",totalWithoutTax:"Cart.PriceSummary.total.withoutTax",totalSaved:"Cart.PriceSummary.total.saved",shippingLabel:"Cart.PriceSummary.shipping.label",zipPlaceholder:"Cart.PriceSummary.shipping.zipPlaceholder",editZipAction:"Cart.PriceSummary.shipping.editZipAction",shippingWithTaxes:"Cart.PriceSummary.shipping.withTaxes",shippingWithoutTaxes:"Cart.PriceSummary.shipping.withoutTaxes",shippingEstimated:"Cart.PriceSummary.shipping.estimated",shippingEstimatedByState:"Cart.PriceSummary.shipping.alternateField.state",shippingEstimatedByZip:"Cart.PriceSummary.shipping.alternateField.zip",destinationLinkAriaLabel:"Cart.PriceSummary.shipping.destinationLinkAriaLabel",applyButton:"Cart.PriceSummary.estimatedShippingForm.apply.label",countryField:"Cart.PriceSummary.estimatedShippingForm.country.placeholder",freeShipping:"Cart.PriceSummary.freeShipping",stateField:"Cart.PriceSummary.estimatedShippingForm.state.placeholder",zipField:"Cart.PriceSummary.estimatedShippingForm.zip.placeholder"}),k=g&&E(v,{label:i.subtotalLabel,price:g.price,classSuffixes:["subTotal"],children:[g.taxIncluded&&r("div",{"data-testid":"sub-total-tax-caption",className:"cart-order-summary__caption",children:r("span",{children:i.subtotalWithTaxes})}),g.taxExcluded?r("div",{"data-testid":"sub-total-tax-caption-excluded",className:"cart-order-summary__caption",children:E("span",{children:[g.priceExcludingTax," ",i.subtotalWithoutTaxes]})}):void 0]}),w=_&&_.length>0&&r(We,{children:_.map(n=>E(v,{label:n.label,price:n.price,classSuffixes:["discount"],children:[n.coupon&&r(B,{node:n.coupon,className:"cart-order-summary__coupon__code"}),n.caption&&r(B,{node:n.caption,className:"cart-order-summary__caption"})]}))}),S=e&&e.length>0?r(Ne,{"data-testid":"tax-breakdown",className:"cart-order-summary__taxes",iconOpen:De,iconClose:Be,children:E(Le,{title:i.taxesBreakdownTitle,secondaryText:!T&&x?r(B,{node:x.price,className:"cart-order-summary__price"}):void 0,renderContentWhenClosed:!1,onStateChange:D,children:[r("div",{className:"cart-order-summary__appliedTaxes",children:e.map(n=>r(v,{label:n.label,price:n.price,classSuffixes:["taxEntry"],labelClassSuffix:"muted"}))}),x&&r(v,{label:i.taxTotal,price:x.price,classSuffixes:["taxTotal"],labelClassSuffix:"muted"})]})}):x&&r(v,{label:x.estimated?i.taxEstimated:i.taxTotalOnly,price:x.price,classSuffixes:["taxTotal"],testId:"tax-total-only"}),d=[{key:"subTotalContent",sortOrder:100,content:k},...m?[{key:"shippingContent",sortOrder:200,content:r(B,{node:m,className:"cart-order-summary__shipping"})}]:[],{key:"discountsContent",sortOrder:300,content:w},{key:"taxContent",sortOrder:400,content:S},...p?[{key:"taxContent",sortOrder:500,content:r(v,{label:p.estimated?i.totalEstimated:i.totalLabel,price:p.price,classSuffixes:["total","total--padded"],testId:"total-content",labelClassSuffix:"bold"})}]:[],...p&&p.priceWithoutTax?[{key:"totalWithoutTaxContent",sortOrder:600,content:r(v,{label:i.totalWithoutTax,price:p.priceWithoutTax,classSuffixes:["totalWithoutTax"],testId:"total-without-tax",labelClassSuffix:"muted"})}]:[],...y?[{key:"totalSavedContent",sortOrder:700,content:r(v,{label:i.totalSaved,price:y,classSuffixes:["saved"],testId:"total-saved",labelClassSuffix:"muted"})}]:[],...L?[{key:"primaryActionContent",sortOrder:800,content:r("div",{className:ke(["cart-order-summary__entry","cart-order-summary__primaryAction"]),children:L})}]:[],...o?[{key:"couponsContent",sortOrder:900,content:r(B,{node:o,className:"cart-order-summary__coupons"})}]:[]],h=I(d).sort((n,C)=>n.sortOrder-C.sortOrder);return E("div",{...t,className:ke(["cart-order-summary",["cart-order-summary--loading",N],[`cart-order-summary__${P}`,P],O]),children:[N&&r(Ze,{className:"cart-order-summary__spinner"}),E("div",{className:"cart-order-summary__heading",children:[s&&r(B,{node:s,className:"cart-order-summary__heading-text"}),r(je,{variant:"primary",className:"cart-order-summary__divider-primary"})]}),r("div",{className:"cart-order-summary__content",children:h.map(n=>Array.isArray(n.content)?r(Ne,{className:n.className,actionIconPosition:"right",iconOpen:De,iconClose:Be,children:r(Le,{defaultOpen:!1,title:n.title,renderContentWhenClosed:!1,children:n.content.map(C=>C.content)})}):n.content)})]})},qe=()=>{const[O,A]=M(!1),[P,s]=M();return{handleEstimateTotals:(g,m)=>{A(!0);const{shippingCountry:_,shippingState:x="",shippingStateId:e,shippingZip:p=""}=g,L={countryCode:_,postcode:p,region:{region:x,id:e},shipping_method:{carrier_code:(m==null?void 0:m.carrier_code)||"",method_code:(m==null?void 0:m.method_code)||""}};ze(L).then(o=>{var y,I,t,T,D,i,k,w,S,d,h,n,C,ee,W,F,G,z,V,Z;o&&s({estimatedTaxTotal:{amount:(y=o.totalTax)==null?void 0:y.value,currency:(I=o.totalTax)==null?void 0:I.currency},estimatedSubTotal:{excludingTax:{amount:(T=(t=o.subtotal)==null?void 0:t.excludingTax)==null?void 0:T.value,currency:(i=(D=o.subtotal)==null?void 0:D.excludingTax)==null?void 0:i.currency},includingTax:{amount:(w=(k=o.subtotal)==null?void 0:k.includingTax)==null?void 0:w.value,currency:(d=(S=o.subtotal)==null?void 0:S.includingTax)==null?void 0:d.currency},includingDiscountOnly:{amount:(n=(h=o.subtotal)==null?void 0:h.includingDiscountOnly)==null?void 0:n.value,currency:(ee=(C=o.subtotal)==null?void 0:C.includingDiscountOnly)==null?void 0:ee.currency}},estimatedGrandTotalPrice:{includingTax:{amount:(W=o.total)==null?void 0:W.includingTax.value,currency:(F=o.total)==null?void 0:F.includingTax.currency},excludingTax:{amount:(G=o.total)==null?void 0:G.excludingTax.value,currency:(z=o.total)==null?void 0:z.excludingTax.currency}},estimatedAppliedTaxes:{taxes:(V=o.appliedTaxes)==null?void 0:V.map(u=>{var b,f;return{label:u.label,amount:{value:(b=u.amount)==null?void 0:b.value,currency:(f=u.amount)==null?void 0:f.currency}}})},estimatedItems:{items:(Z=o.items)==null?void 0:Z.map(u=>{var b,f,j,U,Q,X,$,q,H,R;return{uid:u.uid,price:{amount:(b=u.price)==null?void 0:b.value,currency:(f=u.price)==null?void 0:f.currency},taxedPrice:{amount:(j=u.taxedPrice)==null?void 0:j.value,currency:(U=u.taxedPrice)==null?void 0:U.currency},rowTotal:{amount:(Q=u.rowTotal)==null?void 0:Q.value,currency:(X=u.rowTotal)==null?void 0:X.currency},rowTotalIncludingTax:{amount:($=u.rowTotalIncludingTax)==null?void 0:$.value,currency:(q=u.rowTotalIncludingTax)==null?void 0:q.currency},regularPrice:{amount:(H=u.regularPrice)==null?void 0:H.value,currency:(R=u.regularPrice)==null?void 0:R.currency}}})}})}).finally(()=>{A(!1)})},estimatedTotals:P,setEstimatedTotals:s,loading:O}},He=({children:O,initialData:A=null,routeCheckout:P,slots:s,errors:N,showTotalSaved:g,enableCoupons:m,updateLineItems:_=e=>e,...x})=>{var W,F,G,z,V,Z,u,b,f,j,U,Q,X,$,q,H,R,ie,ne,ce,oe,ue,se,le,me,de,xe,pe,he,ge,ye,Te,Se,Ce,be,fe;const[e,p]=M(A),[L,o]=M(!1),y=e==null?void 0:e.isVirtual;m=m??!0;const{handleEstimateTotals:I,estimatedTotals:t,setEstimatedTotals:T,loading:D}=qe(),i=(W=Oe.config)==null?void 0:W.shoppingCartDisplaySetting,k=(i==null?void 0:i.subtotal)==="INCLUDING_TAX",w=(i==null?void 0:i.subtotal)==="INCLUDING_EXCLUDING_TAX",S=i==null?void 0:i.zeroTax;ae(()=>{const c=Ee.on("cart/data",a=>{var J,K,Y;p(a);const te=(J=a==null?void 0:a.addresses)==null?void 0:J.shipping,re=a==null?void 0:a.isVirtual;(te||re)&&T(null),t==null&&T({estimatedTaxTotal:{amount:(K=a==null?void 0:a.totalTax)==null?void 0:K.value,currency:(Y=a==null?void 0:a.totalTax)==null?void 0:Y.currency}})},{eager:!0});return()=>{c==null||c.off()}},[]),ae(()=>{o(N)},[N]),ae(()=>{const c=Ee.on("shipping/estimate",a=>{var J,K,Y,ve,Pe,_e;const te={shippingCountry:(J=a==null?void 0:a.address)==null?void 0:J.countryCode,shippingState:(K=a==null?void 0:a.address)==null?void 0:K.region,shippingStateId:(Y=a==null?void 0:a.address)==null?void 0:Y.regionId,shippingZip:(ve=a==null?void 0:a.address)==null?void 0:ve.postCode},re={carrier_code:((Pe=a==null?void 0:a.shippingMethod)==null?void 0:Pe.carrierCode)||"",method_code:((_e=a==null?void 0:a.shippingMethod)==null?void 0:_e.methodCode)||""};I(te,re)});return()=>{c==null||c.off()}},[I]);const d=Ae({checkout:"Cart.PriceSummary.checkout",free:"Cart.PriceSummary.total.free",orderSummary:"Cart.PriceSummary.orderSummary",taxToBeDetermined:"Cart.PriceSummary.taxToBeDetermined"}),h=(e==null?void 0:e.hasOutOfStockItems)||L,n=Fe(()=>{!h&&e&&Ve(e,Oe.locale)},[h,e]),C=!y&&(s!=null&&s.EstimateShipping)?r(we,{name:"EstimateShipping",slot:s.EstimateShipping},"estimateShippingId"):void 0;if(!Object.keys(e??{}).length||(e==null?void 0:e.totalQuantity)===0)return null;const ee=m&&(s!=null&&s.Coupons)?r(we,{name:"Coupons",slot:s.Coupons},"couponsId"):void 0;return r($e,{...x,"data-testid":"cart-order-summary",heading:r("div",{children:d.orderSummary}),shipping:C,coupons:ee,loading:D,updateLineItems:_,subTotal:{taxIncluded:k&&!S,taxExcluded:w,zeroTaxSubtotal:S,priceExcludingTax:(F=t==null?void 0:t.estimatedSubTotal)!=null&&F.excludingTax?r(l,{"data-testid":"subtotal",...(G=t==null?void 0:t.estimatedSubTotal)==null?void 0:G.excludingTax}):r(l,{"data-testid":"subtotal",amount:(V=(z=e==null?void 0:e.subtotal)==null?void 0:z.excludingTax)==null?void 0:V.value,currency:(u=(Z=e==null?void 0:e.subtotal)==null?void 0:Z.excludingTax)==null?void 0:u.currency}),price:!S&&k||!S&&w?(b=t==null?void 0:t.estimatedSubTotal)!=null&&b.includingTax?r(l,{"data-testid":"subtotal",...(f=t==null?void 0:t.estimatedSubTotal)==null?void 0:f.includingTax}):r(l,{"data-testid":"subtotal",amount:(j=e==null?void 0:e.subtotal.includingTax)==null?void 0:j.value,currency:(U=e==null?void 0:e.subtotal.includingTax)==null?void 0:U.currency}):r(l,{"data-testid":"subtotal",amount:(X=(Q=e==null?void 0:e.subtotal)==null?void 0:Q.excludingTax)==null?void 0:X.value,currency:(q=($=e==null?void 0:e.subtotal)==null?void 0:$.excludingTax)==null?void 0:q.currency})},discounts:(H=e==null?void 0:e.appliedDiscounts)==null?void 0:H.map(c=>{var a;return{label:c.label,price:r(l,{"data-testid":"summary-discount-total",amount:-c.amount.value,currency:c.amount.currency,sale:!0}),coupon:c!=null&&c.coupon?E("span",{children:[r(Ue,{source:Xe,size:"16"}),(a=c==null?void 0:c.coupon)==null?void 0:a.code]}):void 0}}),taxTotal:y||t&&t.estimatedTaxTotal==null?{price:r("span",{"data-testid":"tax-total-tbd",children:d.taxToBeDetermined})}:{price:t!=null&&t.estimatedTaxTotal?r(l,{"data-testid":"tax-total-estimated",...t==null?void 0:t.estimatedTaxTotal}):r(l,{"data-testid":"tax-total-actual",amount:(R=e==null?void 0:e.totalTax)==null?void 0:R.value,currency:(ie=e==null?void 0:e.totalTax)==null?void 0:ie.currency}),estimated:(!t||!t.estimatedTaxTotal)&&!((ne=e==null?void 0:e.addresses)!=null&&ne.shipping)},taxesApplied:y?void 0:i!=null&&i.fullSummary?(oe=((ce=t==null?void 0:t.estimatedAppliedTaxes)==null?void 0:ce.taxes)||(e==null?void 0:e.appliedTaxes))==null?void 0:oe.map(c=>({label:c.label,price:r(l,{"data-testid":"applied-taxes",amount:c.amount.value,currency:c.amount.currency})})):void 0,total:{price:t!=null&&t.estimatedGrandTotalPrice?((se=(ue=t==null?void 0:t.estimatedGrandTotalPrice)==null?void 0:ue.includingTax)==null?void 0:se.amount)===0?r("span",{"data-testid":"total-including-tax",children:d.free}):r(l,{"data-testid":"total-including-tax-estimated",...(le=t==null?void 0:t.estimatedGrandTotalPrice)==null?void 0:le.includingTax}):((me=e==null?void 0:e.total)==null?void 0:me.includingTax.value)===0?r("span",{"data-testid":"total-including-tax",children:d.free}):r(l,{"data-testid":"total-including-tax-actual",amount:(de=e==null?void 0:e.total)==null?void 0:de.includingTax.value,currency:(xe=e==null?void 0:e.total)==null?void 0:xe.includingTax.currency}),estimated:(!t||!!(t!=null&&t.estimatedTaxTotal))&&!((pe=e==null?void 0:e.addresses)!=null&&pe.shipping),priceWithoutTax:i!=null&&i.grandTotal?t!=null&&t.estimatedAppliedTaxes?((ge=(he=t==null?void 0:t.estimatedGrandTotalPrice)==null?void 0:he.excludingTax)==null?void 0:ge.amount)===0?r("span",{"data-testid":"total-excluding-tax",children:d.free}):r(l,{"data-testid":"total-excluding-tax",...(ye=t==null?void 0:t.estimatedGrandTotalPrice)==null?void 0:ye.excludingTax}):((Te=e==null?void 0:e.total)==null?void 0:Te.excludingTax.value)===0?r("span",{"data-testid":"total-excluding-tax",children:d.free}):r(l,{"data-testid":"total-excluding-tax",amount:(Se=e==null?void 0:e.total)==null?void 0:Se.excludingTax.value,currency:(Ce=e==null?void 0:e.total)==null?void 0:Ce.excludingTax.currency}):void 0},primaryAction:P&&r(Qe,{"data-testid":"checkout-button",variant:"primary",disabled:h,"aria-disabled":h,href:h?void 0:P({cartId:e.id}),onClick:n,children:d.checkout}),totalSaved:g?r(l,{amount:(be=e==null?void 0:e.discount)==null?void 0:be.value,currency:(fe=e==null?void 0:e.total)==null?void 0:fe.includingTax.currency}):void 0})};He.getInitialData=async function(){return Ge()};export{He as O};
|
|
3
|
+
import{jsx as r,jsxs as p,Fragment as xr}from"@dropins/tools/preact-jsx-runtime.js";import{useState as te,useEffect as ie,useCallback as pr,Fragment as Tr}from"@dropins/tools/preact-compat.js";import{VComponent as U,classes as ar,Slot as le}from"@dropins/tools/lib.js";import{events as cr}from"@dropins/tools/event-bus.js";import{g as gr}from"./persisted-data.js";import{s as ce}from"./resetCart.js";import{g as hr}from"./getEstimatedTotals.js";import{p as yr}from"./acdl.js";import"@dropins/tools/preact-hooks.js";import{Accordion as ir,AccordionSection as lr,ProgressSpinner as Cr,Divider as Sr,Price as u,Icon as ur,Button as Ir}from"@dropins/tools/components.js";/* empty css */import{O as C}from"./OrderSummaryLine.js";import{S as or}from"./ChevronDown.js";import{S as sr}from"./ChevronUp.js";import{useText as dr,Text as mr}from"@dropins/tools/i18n.js";import{S as br}from"./Coupon.js";import{S as vr}from"./GiftCard.js";const _r=({className:ne,children:$,variant:w="primary",heading:m,loading:X=!0,subTotal:b,shipping:g,discounts:v,taxTotal:S,taxesApplied:A,total:e,primaryAction:z,coupons:o,giftCards:D,totalSaved:_,appliedGiftCards:d,printedCard:t,itemsGiftWrapping:x,orderGiftWrapping:T,updateLineItems:s=f=>f,...W})=>{const[f,P]=te(!1),l=dr({checkout:"Cart.PriceSummary.checkout",discountedPrice:"Cart.CartItem.discountedPrice",download:"Cart.CartItem.download",heading:"Cart.Cart.heading",message:"Cart.CartItem.message",regularPrice:"Cart.CartItem.regularPrice",recipient:"Cart.CartItem.recipient",sender:"Cart.CartItem.sender",file:"Cart.CartItem.file",files:"Cart.CartItem.files",orderSummary:"Cart.PriceSummary.orderSummary",taxesBreakdownTitle:"Cart.PriceSummary.taxes.breakdown",taxTotal:"Cart.PriceSummary.taxes.total",taxEstimated:"Cart.PriceSummary.taxes.estimated",taxTotalOnly:"Cart.PriceSummary.taxes.totalOnly",showTaxBreakdown:"Cart.PriceSummary.taxes.showBreakdown",hideTaxBreakdown:"Cart.PriceSummary.taxes.hideBreakdown",taxToBeDetermined:"Cart.PriceSummary.taxToBeDetermined",subtotalLabel:"Cart.PriceSummary.subTotal.label",subtotalWithTaxes:"Cart.PriceSummary.subTotal.withTaxes",subtotalWithoutTaxes:"Cart.PriceSummary.subTotal.withoutTaxes",totalEstimated:"Cart.PriceSummary.total.estimated",totalLabel:"Cart.PriceSummary.total.label",totalWithoutTax:"Cart.PriceSummary.total.withoutTax",totalSaved:"Cart.PriceSummary.total.saved",shippingLabel:"Cart.PriceSummary.shipping.label",zipPlaceholder:"Cart.PriceSummary.shipping.zipPlaceholder",editZipAction:"Cart.PriceSummary.shipping.editZipAction",shippingWithTaxes:"Cart.PriceSummary.shipping.withTaxes",shippingWithoutTaxes:"Cart.PriceSummary.shipping.withoutTaxes",shippingEstimated:"Cart.PriceSummary.shipping.estimated",shippingEstimatedByState:"Cart.PriceSummary.shipping.alternateField.state",shippingEstimatedByZip:"Cart.PriceSummary.shipping.alternateField.zip",destinationLinkAriaLabel:"Cart.PriceSummary.shipping.destinationLinkAriaLabel",applyButton:"Cart.PriceSummary.estimatedShippingForm.apply.label",countryField:"Cart.PriceSummary.estimatedShippingForm.country.placeholder",freeShipping:"Cart.PriceSummary.freeShipping",stateField:"Cart.PriceSummary.estimatedShippingForm.state.placeholder",zipField:"Cart.PriceSummary.estimatedShippingForm.zip.placeholder",printedCardTitle:"Cart.PriceSummary.giftOptionsTax.printedCard.title",printedCardInclTax:"Cart.PriceSummary.giftOptionsTax.printedCard.inclTax",printedCardExclTax:"Cart.PriceSummary.giftOptionsTax.printedCard.exclTax",itemGiftWrappingTitle:"Cart.PriceSummary.giftOptionsTax.itemGiftWrapping.title",itemGiftWrappingInclTax:"Cart.PriceSummary.giftOptionsTax.itemGiftWrapping.inclTax",itemGiftWrappingExclTax:"Cart.PriceSummary.giftOptionsTax.itemGiftWrapping.exclTax",orderGiftWrappingTitle:"Cart.PriceSummary.giftOptionsTax.orderGiftWrapping.title",orderGiftWrappingInclTax:"Cart.PriceSummary.giftOptionsTax.orderGiftWrapping.inclTax",orderGiftWrappingExclTax:"Cart.PriceSummary.giftOptionsTax.orderGiftWrapping.exclTax"}),V=d?r(C,{label:d==null?void 0:d.label,price:d==null?void 0:d.price,classSuffixes:["applied-gift-cards"],children:d==null?void 0:d.content}):null,E=b&&p(C,{label:l.subtotalLabel,price:b.price,classSuffixes:["subTotal"],children:[b.taxIncluded&&r("div",{"data-testid":"sub-total-tax-caption",className:"cart-order-summary__caption",children:r("span",{children:l.subtotalWithTaxes})}),b.taxExcluded?r("div",{"data-testid":"sub-total-tax-caption-excluded",className:"cart-order-summary__caption",children:p("span",{children:[b.priceExcludingTax," ",l.subtotalWithoutTaxes]})}):void 0]}),B=v&&v.length>0&&r(xr,{children:v.map(i=>p(C,{label:i.label,price:i.price,classSuffixes:["discount"],children:[i.coupon&&r(U,{node:i.coupon,className:"cart-order-summary__coupon__code"}),i.caption&&r(U,{node:i.caption,className:"cart-order-summary__caption"})]}))}),n=A&&A.length>0?r(ir,{"data-testid":"tax-breakdown",className:"cart-order-summary__taxes",iconOpen:or,iconClose:sr,children:p(lr,{title:l.taxesBreakdownTitle,secondaryText:!f&&S?r(U,{node:S.price,className:"cart-order-summary__price"}):void 0,renderContentWhenClosed:!1,onStateChange:P,children:[r("div",{className:"cart-order-summary__appliedTaxes",children:A.map(i=>r(C,{label:i.label,price:i.price,classSuffixes:["taxEntry"],labelClassSuffix:"muted"}))}),S&&r(C,{label:l.taxTotal,price:S.price,classSuffixes:["taxTotal"],labelClassSuffix:"muted"})]})}):S&&r(C,{label:S.estimated?l.taxEstimated:l.taxTotalOnly,price:S.price,classSuffixes:["taxTotal"],testId:"tax-total-only"}),h=t!=null&&t.renderContent?p(C,{label:l.printedCardTitle,price:t.taxInclAndExcl||t.taxIncluded?t.priceInclTax:t.priceExclTax,classSuffixes:["printedCardContent"],children:[t.taxIncluded&&r("div",{"data-testid":"printed-card-incl",className:"cart-order-summary__caption",children:r("span",{children:l.printedCardInclTax})}),t.taxInclAndExcl?r("div",{"data-testid":"printed-card-incl-excl",className:"cart-order-summary__caption",children:p("span",{children:[t.priceExclTax," ",l.printedCardExclTax]})}):void 0]}):null,I=x!=null&&x.renderContent?p(C,{label:l.itemGiftWrappingTitle,price:x.taxInclAndExcl||x.taxIncluded?x.priceInclTax:x.priceExclTax,classSuffixes:["itemsGiftWrappingContent"],children:[x.taxIncluded?r("div",{"data-testid":"item-gift-wrapping-incl",className:"cart-order-summary__caption",children:r("span",{children:l.itemGiftWrappingInclTax})}):null,x.taxInclAndExcl?r("div",{"data-testid":"item-gift-wrapping-incl-excl",className:"cart-order-summary__caption",children:p("span",{children:[x.priceExclTax," ",l.itemGiftWrappingExclTax]})}):null]}):null,Z=T!=null&&T.renderContent?p(C,{label:l.orderGiftWrappingTitle,price:T.taxInclAndExcl||T.taxIncluded?T.priceInclTax:T.priceExclTax,classSuffixes:["orderGiftWrappingContent"],children:[T.taxIncluded&&r("div",{"data-testid":"order-gift-wrapping-incl",className:"cart-order-summary__caption",children:r("span",{children:l.orderGiftWrappingInclTax})}),T.taxInclAndExcl?r("div",{"data-testid":"order-gift-wrapping-incl-excl",className:"cart-order-summary__caption",children:p("span",{children:[T.priceExclTax," ",l.orderGiftWrappingExclTax]})}):void 0]}):null,j=[{key:"subTotalContent",sortOrder:100,content:E},...g?[{key:"shippingContent",sortOrder:200,content:r(U,{node:g,className:"cart-order-summary__shipping"})}]:[],{key:"printedCard",sortOrder:300,content:h},{key:"itemsGiftWrappingContent",sortOrder:400,content:I},{key:"orderGiftWrappingContent",sortOrder:500,content:Z},{key:"discountsContent",sortOrder:600,content:B},{key:"appliedGiftCardsContent",sortOrder:700,content:V},{key:"taxContent",sortOrder:800,content:n},...e?[{key:"taxContent",sortOrder:900,content:r(C,{label:e.estimated?l.totalEstimated:l.totalLabel,price:e.price,classSuffixes:["total","total--padded"],testId:"total-content",labelClassSuffix:"bold"})}]:[],...e!=null&&e.priceWithoutTax?[{key:"totalWithoutTaxContent",sortOrder:1e3,content:r(C,{label:l.totalWithoutTax,price:e.priceWithoutTax,classSuffixes:["totalWithoutTax"],testId:"total-without-tax",labelClassSuffix:"muted"})}]:[],..._?[{key:"totalSavedContent",sortOrder:1100,content:r(C,{label:l.totalSaved,price:_,classSuffixes:["saved"],testId:"total-saved",labelClassSuffix:"muted"})}]:[],...z?[{key:"primaryActionContent",sortOrder:1200,content:r("div",{className:ar(["cart-order-summary__entry","cart-order-summary__primaryAction"]),children:z})}]:[],...o?[{key:"couponsContent",sortOrder:1300,content:r(U,{node:o,className:"cart-order-summary__coupons"})}]:[],...D?[{key:"giftCardsContent",sortOrder:1400,content:r(U,{node:D,className:"cart-order-summary__gift-cards"})}]:[]],Q=s(j).sort((i,y)=>i.sortOrder-y.sortOrder);return p("div",{...W,className:ar(["cart-order-summary",["cart-order-summary--loading",X],[`cart-order-summary__${w}`,w],ne]),children:[X&&r(Cr,{className:"cart-order-summary__spinner"}),p("div",{className:"cart-order-summary__heading",children:[m&&r(U,{node:m,className:"cart-order-summary__heading-text"}),r(Sr,{variant:"primary",className:"cart-order-summary__divider-primary"})]}),r("div",{className:"cart-order-summary__content",children:Q.map(i=>Array.isArray(i.content)?r(ir,{className:i.className,actionIconPosition:"right",iconOpen:or,iconClose:sr,children:r(lr,{defaultOpen:!1,title:i.title,renderContentWhenClosed:!1,children:i.content.map(y=>y.content)})},i.key):i.content)})]})},fr=()=>{const[ne,$]=te(!1),[w,m]=te();return{handleEstimateTotals:(b,g)=>{$(!0);const{shippingCountry:v,shippingState:S="",shippingStateId:A,shippingZip:e=""}=b,z={countryCode:v,postcode:e,region:{region:S,id:A},shipping_method:{carrier_code:(g==null?void 0:g.carrier_code)||"",method_code:(g==null?void 0:g.method_code)||""}};hr(z).then(o=>{var D,_,d,t,x,T,s,W,f,P,l,V,E,B,n,h,I,Z,j,Q;o&&m({estimatedTaxTotal:{amount:(D=o.totalTax)==null?void 0:D.value,currency:(_=o.totalTax)==null?void 0:_.currency},estimatedSubTotal:{excludingTax:{amount:(t=(d=o.subtotal)==null?void 0:d.excludingTax)==null?void 0:t.value,currency:(T=(x=o.subtotal)==null?void 0:x.excludingTax)==null?void 0:T.currency},includingTax:{amount:(W=(s=o.subtotal)==null?void 0:s.includingTax)==null?void 0:W.value,currency:(P=(f=o.subtotal)==null?void 0:f.includingTax)==null?void 0:P.currency},includingDiscountOnly:{amount:(V=(l=o.subtotal)==null?void 0:l.includingDiscountOnly)==null?void 0:V.value,currency:(B=(E=o.subtotal)==null?void 0:E.includingDiscountOnly)==null?void 0:B.currency}},estimatedGrandTotalPrice:{includingTax:{amount:(n=o.total)==null?void 0:n.includingTax.value,currency:(h=o.total)==null?void 0:h.includingTax.currency},excludingTax:{amount:(I=o.total)==null?void 0:I.excludingTax.value,currency:(Z=o.total)==null?void 0:Z.excludingTax.currency}},estimatedAppliedTaxes:{taxes:(j=o.appliedTaxes)==null?void 0:j.map(i=>{var y,N;return{label:i.label,amount:{value:(y=i.amount)==null?void 0:y.value,currency:(N=i.amount)==null?void 0:N.currency}}})},estimatedItems:{items:(Q=o.items)==null?void 0:Q.map(i=>{var y,N,H,q,J,K,R,Y,G,M;return{uid:i.uid,price:{amount:(y=i.price)==null?void 0:y.value,currency:(N=i.price)==null?void 0:N.currency},taxedPrice:{amount:(H=i.taxedPrice)==null?void 0:H.value,currency:(q=i.taxedPrice)==null?void 0:q.currency},rowTotal:{amount:(J=i.rowTotal)==null?void 0:J.value,currency:(K=i.rowTotal)==null?void 0:K.currency},rowTotalIncludingTax:{amount:(R=i.rowTotalIncludingTax)==null?void 0:R.value,currency:(Y=i.rowTotalIncludingTax)==null?void 0:Y.currency},regularPrice:{amount:(G=i.regularPrice)==null?void 0:G.value,currency:(M=i.regularPrice)==null?void 0:M.currency}}})}})}).finally(()=>{$(!1)})},estimatedTotals:w,setEstimatedTotals:m,loading:ne}},Pr=({children:ne,initialData:$=null,routeCheckout:w,slots:m,errors:X,showTotalSaved:b,enableCoupons:g,enableGiftCards:v,updateLineItems:S=e=>e,...A})=>{var y,N,H,q,J,K,R,Y,G,M,ue,oe,se,me,de,xe,pe,Te,ge,he,ye,Ce,Se,Ie,be,ve,_e,fe,Pe,Ee,Ne,ke,we,Ae,De,We,Be,Le,Fe,Oe,Ue,Xe,ze,Ve,Ze,je,Qe,$e,He,qe,Je,Ke,Re,Ye,Ge,Me,er,rr,tr;const[e,z]=te($),[o,D]=te(!1),_=e==null?void 0:e.isVirtual;g=g??!0,v=v??!0;const{handleEstimateTotals:d,estimatedTotals:t,setEstimatedTotals:x,loading:T}=fr(),s=(y=ce.config)==null?void 0:y.shoppingCartDisplaySetting,W=(s==null?void 0:s.subtotal)==="INCLUDING_TAX",f=(s==null?void 0:s.subtotal)==="INCLUDING_EXCLUDING_TAX",P=s==null?void 0:s.zeroTax,l=()=>(e==null?void 0:e.appliedGiftCards.reduce((a,c)=>a+c.appliedBalance.value,0))??0,V=a=>{var k,ee,re;if(!(a!=null&&a.code))return null;const c=(k=a==null?void 0:a.currentBalance)==null?void 0:k.value,L=(ee=a==null?void 0:a.appliedBalance)==null?void 0:ee.value,F=c-L!==0?c-L:L,O=(re=a==null?void 0:a.currentBalance)==null?void 0:re.currency;return p(Tr,{children:[p("span",{className:"cart-order-summary__coupon__code",children:[r(ur,{source:vr,size:"16"}),r("span",{children:a==null?void 0:a.code})]}),p("span",{className:"cart-order-summary__caption",children:[r(mr,{id:"Cart.PriceSummary.giftCard.appliedGiftCards.remainingBalance"}),r(u,{className:"cart-order-summary__caption",weight:"normal",size:"small",amount:F,currency:O})]})]},a.code)},E=(N=ce.config)==null?void 0:N.cartGiftWrapping,B=(H=ce.config)==null?void 0:H.cartPrintedCard,n=e==null?void 0:e.totalGiftOptions;ie(()=>{const a=cr.on("cart/data",c=>{var F,O,k;z(c);const L=(F=c==null?void 0:c.addresses)==null?void 0:F.shipping,ae=c==null?void 0:c.isVirtual;(L||ae)&&x(null),t==null&&x({estimatedTaxTotal:{amount:(O=c==null?void 0:c.totalTax)==null?void 0:O.value,currency:(k=c==null?void 0:c.totalTax)==null?void 0:k.currency}})},{eager:!0});return()=>{a==null||a.off()}},[]),ie(()=>{D(X)},[X]),ie(()=>{const a=cr.on("shipping/estimate",c=>{var F,O,k,ee,re,nr;const L={shippingCountry:(F=c==null?void 0:c.address)==null?void 0:F.countryCode,shippingState:(O=c==null?void 0:c.address)==null?void 0:O.region,shippingStateId:(k=c==null?void 0:c.address)==null?void 0:k.regionId,shippingZip:(ee=c==null?void 0:c.address)==null?void 0:ee.postCode},ae={carrier_code:((re=c==null?void 0:c.shippingMethod)==null?void 0:re.carrierCode)||"",method_code:((nr=c==null?void 0:c.shippingMethod)==null?void 0:nr.methodCode)||""};d(L,ae)});return()=>{a==null||a.off()}},[d]);const h=dr({checkout:"Cart.PriceSummary.checkout",free:"Cart.PriceSummary.total.free",orderSummary:"Cart.PriceSummary.orderSummary",taxToBeDetermined:"Cart.PriceSummary.taxToBeDetermined"}),I=(e==null?void 0:e.hasOutOfStockItems)||o,Z=pr(()=>{!I&&e&&yr(e,ce.locale)},[I,e]),j=!_&&(m!=null&&m.EstimateShipping)?r(le,{name:"EstimateShipping",slot:m.EstimateShipping},"estimateShippingId"):void 0;if(!Object.keys(e??{}).length||(e==null?void 0:e.totalQuantity)===0)return null;const Q=g&&(m!=null&&m.Coupons)?r(le,{name:"Coupons",slot:m.Coupons},"couponsId"):void 0,i=v&&(m!=null&&m.GiftCards)?r(le,{name:"GiftCards",slot:m.GiftCards},"giftCardId"):void 0;return r(_r,{...A,"data-testid":"cart-order-summary",heading:r("div",{children:h.orderSummary}),shipping:j,coupons:Q,giftCards:i,loading:T,updateLineItems:S,appliedGiftCards:(q=e==null?void 0:e.appliedGiftCards)!=null&&q.length?{label:r(mr,{id:"Cart.PriceSummary.giftCard.appliedGiftCards.label",plural:(J=e==null?void 0:e.appliedGiftCards)==null?void 0:J.length,fields:{count:(K=e==null?void 0:e.appliedGiftCards)==null?void 0:K.length}}),price:r(u,{className:"cart-order-summary__price",amount:-l(),currency:(Y=(R=e==null?void 0:e.appliedGiftCards)==null?void 0:R[0])==null?void 0:Y.appliedBalance.currency}),content:(G=e==null?void 0:e.appliedGiftCards)==null?void 0:G.map(V).filter(Boolean)}:void 0,printedCard:{renderContent:!!((M=n==null?void 0:n.printedCard)!=null&&M.value),taxIncluded:B==="INCLUDING_TAX",taxInclAndExcl:B==="INCLUDING_EXCLUDING_TAX",priceExclTax:r(u,{"data-testid":"printed-card",amount:(ue=n==null?void 0:n.printedCard)==null?void 0:ue.value,currency:(oe=n==null?void 0:n.printedCard)==null?void 0:oe.currency}),priceInclTax:r(u,{amount:(se=n==null?void 0:n.printedCardInclTax)==null?void 0:se.value,currency:(me=n==null?void 0:n.printedCardInclTax)==null?void 0:me.currency})},itemsGiftWrapping:{renderContent:!!((de=n==null?void 0:n.giftWrappingForItems)!=null&&de.value),taxIncluded:E==="INCLUDING_TAX",taxInclAndExcl:E==="INCLUDING_EXCLUDING_TAX",priceExclTax:r(u,{amount:(xe=n==null?void 0:n.giftWrappingForItems)==null?void 0:xe.value,currency:(pe=n==null?void 0:n.giftWrappingForItems)==null?void 0:pe.currency}),priceInclTax:r(u,{amount:(Te=n==null?void 0:n.giftWrappingForItemsInclTax)==null?void 0:Te.value,currency:(ge=n==null?void 0:n.giftWrappingForItemsInclTax)==null?void 0:ge.currency})},orderGiftWrapping:{renderContent:!!((he=n==null?void 0:n.giftWrappingForOrder)!=null&&he.value),taxIncluded:E==="INCLUDING_TAX",taxInclAndExcl:E==="INCLUDING_EXCLUDING_TAX",priceExclTax:r(u,{amount:(ye=n==null?void 0:n.giftWrappingForOrder)==null?void 0:ye.value,currency:(Ce=n==null?void 0:n.giftWrappingForOrder)==null?void 0:Ce.currency}),priceInclTax:r(u,{amount:(Se=n==null?void 0:n.giftWrappingForOrderInclTax)==null?void 0:Se.value,currency:(Ie=n==null?void 0:n.giftWrappingForOrderInclTax)==null?void 0:Ie.currency})},subTotal:{taxIncluded:W&&!P,taxExcluded:f,zeroTaxSubtotal:P,priceExcludingTax:(be=t==null?void 0:t.estimatedSubTotal)!=null&&be.excludingTax?r(u,{"data-testid":"subtotal",...(ve=t==null?void 0:t.estimatedSubTotal)==null?void 0:ve.excludingTax}):r(u,{"data-testid":"subtotal",amount:(fe=(_e=e==null?void 0:e.subtotal)==null?void 0:_e.excludingTax)==null?void 0:fe.value,currency:(Ee=(Pe=e==null?void 0:e.subtotal)==null?void 0:Pe.excludingTax)==null?void 0:Ee.currency}),price:!P&&W||!P&&f?(Ne=t==null?void 0:t.estimatedSubTotal)!=null&&Ne.includingTax?r(u,{"data-testid":"subtotal",...(ke=t==null?void 0:t.estimatedSubTotal)==null?void 0:ke.includingTax}):r(u,{"data-testid":"subtotal",amount:(we=e==null?void 0:e.subtotal.includingTax)==null?void 0:we.value,currency:(Ae=e==null?void 0:e.subtotal.includingTax)==null?void 0:Ae.currency}):r(u,{"data-testid":"subtotal",amount:(We=(De=e==null?void 0:e.subtotal)==null?void 0:De.excludingTax)==null?void 0:We.value,currency:(Le=(Be=e==null?void 0:e.subtotal)==null?void 0:Be.excludingTax)==null?void 0:Le.currency})},discounts:(Fe=e==null?void 0:e.appliedDiscounts)==null?void 0:Fe.map(a=>{var c;return{label:a.label,price:r(u,{"data-testid":"summary-discount-total",amount:-a.amount.value,currency:a.amount.currency,sale:!0}),coupon:a!=null&&a.coupon?p("span",{children:[r(ur,{source:br,size:"16"}),(c=a==null?void 0:a.coupon)==null?void 0:c.code]}):void 0}}),taxTotal:_||t&&t.estimatedTaxTotal==null?{price:r("span",{"data-testid":"tax-total-tbd",children:h.taxToBeDetermined})}:{price:t!=null&&t.estimatedTaxTotal?r(u,{"data-testid":"tax-total-estimated",...t==null?void 0:t.estimatedTaxTotal}):r(u,{"data-testid":"tax-total-actual",amount:(Oe=e==null?void 0:e.totalTax)==null?void 0:Oe.value,currency:(Ue=e==null?void 0:e.totalTax)==null?void 0:Ue.currency}),estimated:(!t||!t.estimatedTaxTotal)&&!((Xe=e==null?void 0:e.addresses)!=null&&Xe.shipping)},taxesApplied:_?void 0:s!=null&&s.fullSummary?(Ve=((ze=t==null?void 0:t.estimatedAppliedTaxes)==null?void 0:ze.taxes)||(e==null?void 0:e.appliedTaxes))==null?void 0:Ve.map(a=>({label:a.label,price:r(u,{"data-testid":"applied-taxes",amount:a.amount.value,currency:a.amount.currency})})):void 0,total:{price:t!=null&&t.estimatedGrandTotalPrice?((je=(Ze=t==null?void 0:t.estimatedGrandTotalPrice)==null?void 0:Ze.includingTax)==null?void 0:je.amount)===0?r("span",{"data-testid":"total-including-tax",children:h.free}):r(u,{"data-testid":"total-including-tax-estimated",...(Qe=t==null?void 0:t.estimatedGrandTotalPrice)==null?void 0:Qe.includingTax}):(($e=e==null?void 0:e.total)==null?void 0:$e.includingTax.value)===0?r("span",{"data-testid":"total-including-tax",children:h.free}):r(u,{"data-testid":"total-including-tax-actual",amount:(He=e==null?void 0:e.total)==null?void 0:He.includingTax.value,currency:(qe=e==null?void 0:e.total)==null?void 0:qe.includingTax.currency}),estimated:(!t||!!(t!=null&&t.estimatedTaxTotal))&&!((Je=e==null?void 0:e.addresses)!=null&&Je.shipping),priceWithoutTax:s!=null&&s.grandTotal?t!=null&&t.estimatedAppliedTaxes?((Re=(Ke=t==null?void 0:t.estimatedGrandTotalPrice)==null?void 0:Ke.excludingTax)==null?void 0:Re.amount)===0?r("span",{"data-testid":"total-excluding-tax",children:h.free}):r(u,{"data-testid":"total-excluding-tax",...(Ye=t==null?void 0:t.estimatedGrandTotalPrice)==null?void 0:Ye.excludingTax}):((Ge=e==null?void 0:e.total)==null?void 0:Ge.excludingTax.value)===0?r("span",{"data-testid":"total-excluding-tax",children:h.free}):r(u,{"data-testid":"total-excluding-tax",amount:(Me=e==null?void 0:e.total)==null?void 0:Me.excludingTax.value,currency:(er=e==null?void 0:e.total)==null?void 0:er.excludingTax.currency}):void 0},primaryAction:w&&r(Ir,{"data-testid":"checkout-button",variant:"primary",disabled:I,"aria-disabled":I,href:I?void 0:w({cartId:e.id}),onClick:Z,children:h.checkout}),totalSaved:b?r(u,{amount:(rr=e==null?void 0:e.discount)==null?void 0:rr.value,currency:(tr=e==null?void 0:e.total)==null?void 0:tr.includingTax.currency}):void 0})};Pr.getInitialData=async function(){return gr()};export{Pr as O};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsxs as _,jsx as n}from"@dropins/tools/preact-jsx-runtime.js";import{classes as c,VComponent as y}from"@dropins/tools/lib.js";import"@dropins/tools/components.js";/* empty css
|
|
3
|
+
import{jsxs as _,jsx as n}from"@dropins/tools/preact-jsx-runtime.js";import{classes as c,VComponent as y}from"@dropins/tools/lib.js";import"@dropins/tools/components.js";/* empty css */import"@dropins/tools/preact-compat.js";import"@dropins/tools/preact-hooks.js";const $=({label:e,price:a,classSuffixes:o=[],labelClassSuffix:r,testId:m,children:s,...t})=>{const p="cart-order-summary__label",d="cart-order-summary__price";return _("div",{...t,...m?{"data-testid":m}:{},className:c(["cart-order-summary__entry",...o.map(i=>`cart-order-summary__${i}`)]),children:[n("span",{className:c([p,...r?[`${p}--${r}`]:[]]),children:e}),n(y,{node:a,className:c([d,...r?[`${d}--${r}`]:[]])}),s]})},L=({label:e,price:a,classSuffixes:o=[],labelClassSuffix:r,testId:m,children:s,...t})=>n($,{...t,label:e,price:a,classSuffixes:o,labelClassSuffix:r,testId:m,children:s});export{L as O};
|