@dropins/storefront-cart 1.6.0-alpha2 → 1.6.0-alpha3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsxs as
|
|
3
|
+
import{jsxs as l,jsx as e}from"@dropins/tools/preact-jsx-runtime.js";import{classes as I}from"@dropins/tools/lib.js";import{Price as o}from"@dropins/tools/components.js";/* empty css */import{useState as y,useEffect as T}from"@dropins/tools/preact-compat.js";import{O as N}from"./OrderSummaryLine.js";import{Text as h,useText as L}from"@dropins/tools/i18n.js";import"@dropins/tools/preact-hooks.js";import{s as v}from"./state.js";import{events as O}from"@dropins/tools/event-bus.js";const E=({loading:g,price:s,priceExcludingTax:i,priceIncludingTax:t,taxExcluded:c,taxIncluded:p})=>{const u=["shipping",...g?["shipping--loading"]:[]];return l(N,{testId:"shipping-order-summary-line",classSuffixes:u,label:e(h,{id:"Cart.ShippingOrderSummaryLine.label"}),price:s,children:[p&&e("div",{"data-testid":"shipping-tax-included",className:I(["cart-shipping-order-summary-line__caption"]),children:l("span",{children:[t," ",e(h,{id:"Cart.ShippingOrderSummaryLine.withTaxes"})]})}),c&&e("div",{"data-testid":"shipping-tax-included-excluded",className:I(["cart-shipping-order-summary-line__caption"]),children:l("span",{children:[i," ",e(h,{id:"Cart.ShippingOrderSummaryLine.withoutTaxes"})]})})]})},w=({children:g,...s})=>{var x;const[i,t]=y(null),[c,p]=y(!1),u=L({freeShipping:"Cart.PriceSummary.freeShipping"});if(T(()=>{const d=O.on("cart/data",n=>{var S,f;p((n==null?void 0:n.isVirtual)||!1);const a=(f=(S=n==null?void 0:n.addresses)==null?void 0:S.shipping)==null?void 0:f[0];a!=null&&a.selectedShippingMethod?t(a.selectedShippingMethod):t(null)},{eager:!0});return()=>{d==null||d.off()}},[]),c||!i)return null;const r=(x=v.config)==null?void 0:x.shoppingCartDisplaySetting,m=i.amount.value===0,_=()=>(r==null?void 0:r.shipping)==="INCLUDING_TAX"&&i.amountInclTax?{amount:i.amountInclTax.value,currency:i.amountInclTax.currency}:{amount:i.amount.value,currency:i.amount.currency};return e(E,{...s,loading:!1,taxIncluded:(r==null?void 0:r.shipping)==="INCLUDING_TAX",taxExcluded:(r==null?void 0:r.shipping)==="INCLUDING_EXCLUDING_TAX",price:m?e("span",{"data-testid":"free-shipping",children:u.freeShipping}):e(o,{className:"cart-order-summary__price","data-testid":"shipping-price",..._()}),priceIncludingTax:!m&&i.amountInclTax?e(o,{className:"cart-order-summary__price","data-testid":"shipping-price-including-tax",amount:i.amountInclTax.value,currency:i.amountInclTax.currency}):void 0,priceExcludingTax:!m&&i.amountExclTax?e(o,{className:"cart-order-summary__price","data-testid":"shipping-price-excluding-tax",amount:i.amountExclTax.value,currency:i.amountExclTax.currency}):void 0})};export{w as S};
|
|
4
4
|
//# sourceMappingURL=ShippingOrderSummaryLine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShippingOrderSummaryLine.js","sources":["/@dropins/storefront-cart/src/components/ShippingOrderSummaryLine/ShippingOrderSummaryLine.tsx","/@dropins/storefront-cart/src/containers/ShippingOrderSummaryLine/ShippingOrderSummaryLine.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Text } from '@adobe-commerce/elsie/i18n';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { OrderSummaryLine } from '@/cart/components/OrderSummaryLine/OrderSummaryLine';\n\nimport '@/cart/components/ShippingOrderSummaryLine/ShippingOrderSummaryLine.css';\n\nexport interface ShippingOrderSummaryLineProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'loading'> {\n loading: boolean;\n price: VNode<HTMLAttributes<HTMLSpanElement>>;\n priceExcludingTax?: VNode<HTMLAttributes<HTMLSpanElement>>;\n priceIncludingTax?: VNode<HTMLAttributes<HTMLSpanElement>>;\n taxExcluded?: boolean;\n taxIncluded?: boolean;\n}\n\nexport const ShippingOrderSummaryLine: FunctionComponent<ShippingOrderSummaryLineProps> = ({\n loading,\n price,\n priceExcludingTax,\n priceIncludingTax,\n taxExcluded,\n taxIncluded,\n}) => {\n const classSuffixes = [\n 'shipping',\n ...(loading ? ['shipping--loading'] : []),\n ];\n\n return (\n <OrderSummaryLine\n testId=\"shipping-order-summary-line\"\n classSuffixes={classSuffixes}\n label={<Text id=\"Cart.ShippingOrderSummaryLine.label\" />}\n price={price}\n >\n {taxIncluded && (\n <div\n data-testid=\"shipping-tax-included\"\n className={classes(['cart-shipping-order-summary-line__caption'])}\n >\n <span>\n {priceIncludingTax} <Text id=\"Cart.ShippingOrderSummaryLine.withTaxes\" />\n </span>\n </div>\n )}\n\n {taxExcluded && (\n <div\n data-testid=\"shipping-tax-included-excluded\"\n className={classes(['cart-shipping-order-summary-line__caption'])}\n >\n <span>\n {priceExcludingTax} <Text id=\"Cart.ShippingOrderSummaryLine.withoutTaxes\" />\n </span>\n </div>\n )}\n </OrderSummaryLine>\n );\n};\n\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { ShippingOrderSummaryLine as ShippingOrderSummaryLineComponent } from '@/cart/components';\nimport { state } from '@/cart/lib/state';\nimport { Price } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { ShippingMethod } from '@/cart/data/models/shipping-models';\n\nexport interface ShippingOrderSummaryLineProps extends HTMLAttributes<HTMLDivElement> {}\n\nexport const ShippingOrderSummaryLine: Container<ShippingOrderSummaryLineProps> = ({\n children,\n ...props\n}) => {\n const [selectedShippingMethod, setSelectedShippingMethod] =\n useState<ShippingMethod | null>(null);\n const [isVirtual, setIsVirtual] = useState(false);\n\n const dictionary = useText({\n
|
|
1
|
+
{"version":3,"file":"ShippingOrderSummaryLine.js","sources":["/@dropins/storefront-cart/src/components/ShippingOrderSummaryLine/ShippingOrderSummaryLine.tsx","/@dropins/storefront-cart/src/containers/ShippingOrderSummaryLine/ShippingOrderSummaryLine.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Text } from '@adobe-commerce/elsie/i18n';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { OrderSummaryLine } from '@/cart/components/OrderSummaryLine/OrderSummaryLine';\n\nimport '@/cart/components/ShippingOrderSummaryLine/ShippingOrderSummaryLine.css';\n\nexport interface ShippingOrderSummaryLineProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'loading'> {\n loading: boolean;\n price: VNode<HTMLAttributes<HTMLSpanElement>>;\n priceExcludingTax?: VNode<HTMLAttributes<HTMLSpanElement>>;\n priceIncludingTax?: VNode<HTMLAttributes<HTMLSpanElement>>;\n taxExcluded?: boolean;\n taxIncluded?: boolean;\n}\n\nexport const ShippingOrderSummaryLine: FunctionComponent<ShippingOrderSummaryLineProps> = ({\n loading,\n price,\n priceExcludingTax,\n priceIncludingTax,\n taxExcluded,\n taxIncluded,\n}) => {\n const classSuffixes = [\n 'shipping',\n ...(loading ? ['shipping--loading'] : []),\n ];\n\n return (\n <OrderSummaryLine\n testId=\"shipping-order-summary-line\"\n classSuffixes={classSuffixes}\n label={<Text id=\"Cart.ShippingOrderSummaryLine.label\" />}\n price={price}\n >\n {taxIncluded && (\n <div\n data-testid=\"shipping-tax-included\"\n className={classes(['cart-shipping-order-summary-line__caption'])}\n >\n <span>\n {priceIncludingTax} <Text id=\"Cart.ShippingOrderSummaryLine.withTaxes\" />\n </span>\n </div>\n )}\n\n {taxExcluded && (\n <div\n data-testid=\"shipping-tax-included-excluded\"\n className={classes(['cart-shipping-order-summary-line__caption'])}\n >\n <span>\n {priceExcludingTax} <Text id=\"Cart.ShippingOrderSummaryLine.withoutTaxes\" />\n </span>\n </div>\n )}\n </OrderSummaryLine>\n );\n};\n\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { ShippingOrderSummaryLine as ShippingOrderSummaryLineComponent } from '@/cart/components';\nimport { state } from '@/cart/lib/state';\nimport { Price } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { ShippingMethod } from '@/cart/data/models/shipping-models';\n\nexport interface ShippingOrderSummaryLineProps extends HTMLAttributes<HTMLDivElement> {}\n\nexport const ShippingOrderSummaryLine: Container<ShippingOrderSummaryLineProps> = ({\n children,\n ...props\n}) => {\n const [selectedShippingMethod, setSelectedShippingMethod] =\n useState<ShippingMethod | null>(null);\n const [isVirtual, setIsVirtual] = useState(false);\n\n const dictionary = useText({\n freeShipping: 'Cart.PriceSummary.freeShipping',\n });\n\n useEffect(() => {\n const cartEvent = events.on(\n 'cart/data',\n (payload) => {\n setIsVirtual(payload?.isVirtual || false);\n\n const shippingAddress = payload?.addresses?.shipping?.[0];\n\n if (shippingAddress?.selectedShippingMethod) {\n setSelectedShippingMethod(shippingAddress.selectedShippingMethod);\n } else {\n setSelectedShippingMethod(null);\n }\n },\n { eager: true }\n );\n\n return () => {\n cartEvent?.off();\n };\n }, []);\n\n // Don't render if cart is virtual or no shipping method is selected\n if (isVirtual || !selectedShippingMethod) return null;\n\n const cartTaxesConfig = state.config?.shoppingCartDisplaySetting;\n const isFreeShipping = selectedShippingMethod.amount.value === 0;\n\n const getShippingPriceProps = () => {\n if (cartTaxesConfig?.shipping === 'INCLUDING_TAX' && selectedShippingMethod.amountInclTax) {\n return {\n amount: selectedShippingMethod.amountInclTax.value,\n currency: selectedShippingMethod.amountInclTax.currency,\n };\n }\n return {\n amount: selectedShippingMethod.amount.value,\n currency: selectedShippingMethod.amount.currency,\n };\n };\n\n return (\n <ShippingOrderSummaryLineComponent\n {...props}\n loading={false}\n taxIncluded={cartTaxesConfig?.shipping === 'INCLUDING_TAX'}\n taxExcluded={cartTaxesConfig?.shipping === 'INCLUDING_EXCLUDING_TAX'}\n price={\n isFreeShipping ? (\n <span data-testid=\"free-shipping\">{dictionary.freeShipping}</span>\n ) : (\n <Price\n className=\"cart-order-summary__price\"\n data-testid=\"shipping-price\"\n {...getShippingPriceProps()}\n />\n )\n }\n priceIncludingTax={!isFreeShipping && selectedShippingMethod.amountInclTax ? (\n <Price\n className=\"cart-order-summary__price\"\n data-testid=\"shipping-price-including-tax\"\n amount={selectedShippingMethod.amountInclTax.value}\n currency={selectedShippingMethod.amountInclTax.currency}\n />\n ) : undefined}\n priceExcludingTax={!isFreeShipping && selectedShippingMethod.amountExclTax ? (\n <Price\n className=\"cart-order-summary__price\"\n data-testid=\"shipping-price-excluding-tax\"\n amount={selectedShippingMethod.amountExclTax.value}\n currency={selectedShippingMethod.amountExclTax.currency}\n />\n ) : undefined}\n />\n );\n};\n\n"],"names":["ShippingOrderSummaryLine","loading","price","priceExcludingTax","priceIncludingTax","taxExcluded","taxIncluded","classSuffixes","jsxs","OrderSummaryLine","jsx","Text","classes","children","props","selectedShippingMethod","setSelectedShippingMethod","useState","isVirtual","setIsVirtual","dictionary","useText","useEffect","cartEvent","events","payload","shippingAddress","_b","_a","cartTaxesConfig","state","isFreeShipping","getShippingPriceProps","ShippingOrderSummaryLineComponent","Price"],"mappings":"kfAmCO,MAAMA,EAA6E,CAAC,CACzF,QAAAC,EACA,MAAAC,EACA,kBAAAC,EACA,kBAAAC,EACA,YAAAC,EACA,YAAAC,CACF,IAAM,CACJ,MAAMC,EAAgB,CACpB,WACA,GAAIN,EAAU,CAAC,mBAAmB,EAAI,CAAA,CACxC,EAGE,OAAAO,EAACC,EAAA,CACC,OAAO,8BACP,cAAAF,EACA,MAAOG,EAACC,EAAK,CAAA,GAAG,qCAAsC,CAAA,EACtD,MAAAT,EAEC,SAAA,CACCI,GAAAI,EAAC,MAAA,CACC,cAAY,wBACZ,UAAWE,EAAQ,CAAC,2CAA2C,CAAC,EAEhE,WAAC,OACE,CAAA,SAAA,CAAAR,EAAkB,IAACM,EAACC,EAAK,CAAA,GAAG,yCAA0C,CAA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AAae,GAAA,YAAAA,EAAiB,YAAa,gBAC3C,aAAaA,GAAA,YAAAA,EAAiB,YAAa,0BAC3C,MACEE,EACGrB,EAAA,OAAA,CAAK,cAAY,gBAAiB,SAAAU,EAAW,aAAa,EAE3DV,EAACwB,EAAA,CACC,UAAU,4BACR,cAAY,iBACX,GAAGF,EAAsB,CAAA,CAC9B,EAGJ,kBAAmB,CAACD,GAAkBhB,EAAuB,cAC3DL,EAACwB,EAAA,CACC,UAAU,4BACV,cAAY,+BACZ,OAAQnB,EAAuB,cAAc,MAC7C,SAAUA,EAAuB,cAAc,QAAA,CAAA,EAE/C,OACJ,kBAAmB,CAACgB,GAAkBhB,EAAuB,cAC3DL,EAACwB,EAAA,CACC,UAAU,4BACV,cAAY,+BACZ,OAAQnB,EAAuB,cAAc,MAC7C,SAAUA,EAAuB,cAAc,QAAA,CAAA,EAE/C,MAAA,CACN,CAEJ"}
|
|
@@ -10,10 +10,8 @@ export interface PartialAddress {
|
|
|
10
10
|
export interface ShippingMethod {
|
|
11
11
|
amount: Price;
|
|
12
12
|
carrierCode: string;
|
|
13
|
-
carrierTitle: string;
|
|
14
13
|
methodCode: string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
priceInclTax: Price;
|
|
14
|
+
amountExclTax?: Price;
|
|
15
|
+
amountInclTax?: Price;
|
|
18
16
|
}
|
|
19
17
|
//# sourceMappingURL=shipping-models.d.ts.map
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-cart", "version": "1.6.0-
|
|
1
|
+
{"name": "@dropins/storefront-cart", "version": "1.6.0-alpha3", "@dropins/tools": "1.6.0-beta1", "license": "SEE LICENSE IN LICENSE.md"}
|