@dropins/storefront-checkout 0.1.0-alpha52 → 0.1.0-alpha53
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,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{s as i,d as v,a as A,c as l}from"./store-config.js";import"./ServerErrorSignal.js";import{events as s}from"@dropins/tools/event-bus.js";import{merge as a,Initializer as b}from"@dropins/tools/lib.js";import{M,d as u,k as T}from"./fetch-graphql.js";import{CHECKOUT_DATA_FRAGMENT as m,CUSTOMER_FRAGMENT as I}from"../fragments.js";const S=async(e=!1)=>{i.authenticated=e,e?await K():v.value={pending:!1,data:null}},x=e=>e==null,E=(e,t)=>e.amount.value-t.amount.value,f=e=>!(!e||!e.method_code||!e.method_title||x(e.amount.value)||!e.amount.currency),d=e=>({amount:{value:e.amount.value,currency:e.amount.currency},title:e.method_title,code:e.method_code,carrier:{code:e.carrier_code,title:e.carrier_title},value:`${e.carrier_code} - ${e.method_code}`,...e.price_excl_tax&&{amountExclTax:{value:e.price_excl_tax.value,currency:e.price_excl_tax.currency}},...e.price_incl_tax&&{amountInclTax:{value:e.price_incl_tax.value,currency:e.price_incl_tax.currency}}}),N=e=>{if(f(e))return d(e)},w=e=>{if(e)return e.filter(f).map(t=>d(t)).sort(E)},
|
|
3
|
+
import{s as i,d as v,a as A,c as l}from"./store-config.js";import"./ServerErrorSignal.js";import{events as s}from"@dropins/tools/event-bus.js";import{merge as a,Initializer as b}from"@dropins/tools/lib.js";import{M,d as u,k as T}from"./fetch-graphql.js";import{CHECKOUT_DATA_FRAGMENT as m,CUSTOMER_FRAGMENT as I}from"../fragments.js";const S=async(e=!1)=>{i.authenticated=e,e?await K():v.value={pending:!1,data:null}},x=e=>e==null,E=(e,t)=>e.amount.value-t.amount.value,f=e=>!(!e||!e.method_code||!e.method_title||x(e.amount.value)||!e.amount.currency),d=e=>({amount:{value:e.amount.value,currency:e.amount.currency},title:e.method_title,code:e.method_code,carrier:{code:e.carrier_code,title:e.carrier_title},value:`${e.carrier_code} - ${e.method_code}`,...e.price_excl_tax&&{amountExclTax:{value:e.price_excl_tax.value,currency:e.price_excl_tax.currency}},...e.price_incl_tax&&{amountInclTax:{value:e.price_incl_tax.value,currency:e.price_incl_tax.currency}}}),N=e=>{if(f(e))return d(e)},w=e=>{if(e)return e.filter(f).map(t=>d(t)).sort(E)},k=e=>e?!!e.code&&!!e.label:!1,z=e=>{if(!k(e))return;const{code:t,label:n,region_id:r}=e;return r?{code:t,name:n,id:r}:{code:t,name:n}},R=e=>{const{code:t,label:n}=e;return{value:t,label:n}},q=e=>e?"code"in e&&"value"in e:!1,G=e=>e.filter(q).map(t=>{const{code:n,value:r}=t;return{code:n,value:r}}),p=e=>{const t=e.street.filter(Boolean);return{id:(e==null?void 0:e.id)||void 0,city:e.city,company:e.company||void 0,country:R(e.country),customAttributes:G(e.custom_attributes),firstName:e.firstname,lastName:e.lastname,postCode:e.postcode||void 0,region:z(e.region),street:t,telephone:e.telephone||void 0,vatId:e.vat_id||void 0}},O=e=>{if(e)return p(e)},P=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:n,selected_shipping_method:r,same_as_billing:o,...C}=t;return{...p(C),availableShippingMethods:w(n),selectedShippingMethod:N(r),sameAsBilling:o}}),ee=e=>({city:e.city,company:e.company,country_code:e.countryCode,custom_attributes:e.customAttributes.map(t=>({attribute_code:t.code,value:t.value})),firstname:e.firstName,lastname:e.lastName,postcode:e.postcode,region:e.region,region_id:e.regionId,save_in_address_book:e.saveInAddressBook??!0,street:e.street,telephone:e.telephone,vat_id:e.vatId}),$=e=>{if(e)return{code:e.code,title:e.title}},B=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:n,title:r}=t;return{code:n,title:r}})},F=e=>{var n,r,o;if(!e)return;const t={availablePaymentMethods:B(e.available_payment_methods),billingAddress:O(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:$(e.selected_payment_method),shippingAddresses:P(e.shipping_addresses),isGuest:!i.authenticated};return a(t,(o=(r=(n=_.getConfig().models)==null?void 0:n.CartModel)==null?void 0:r.transformer)==null?void 0:o.call(r,e))},U=e=>{var n,r,o;if(!e)return;const t={firstName:e.firstname||"",lastName:e.lastname||"",email:e.email||""};return a(t,(o=(r=(n=_.getConfig().models)==null?void 0:n.CustomerModel)==null?void 0:r.transformer)==null?void 0:o.call(r,e))},D=`
|
|
4
4
|
query getCart($cartId: String!) {
|
|
5
5
|
cart(cart_id: $cartId) {
|
|
6
6
|
...CHECKOUT_DATA_FRAGMENT
|
|
@@ -24,4 +24,4 @@ import{s as i,d as v,a as A,c as l}from"./store-config.js";import"./ServerErrorS
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
${I}
|
|
27
|
-
`,K=async()=>{if(i.authenticated)return await u({type:"query",query:H,options:{method:"POST",cache:"no-cache"},path:"customer",signalType:"customer",transformer:U})},Q=()=>[s.on("authenticated",S,{eager:!0}),s.on("cart/initialized",h,{eager:!0}),s.on("cart/reset",y),s.on("cart/updated",L)],g=new b({init:async e=>{const t=e||{};g.config.setConfig(t),A.value.data||await T()},listeners:Q}),_=g.config,h=async e=>{if(!e)i.cartId=null,l.value={pending:!1,data:null},
|
|
27
|
+
`,K=async()=>{if(i.authenticated)return await u({type:"query",query:H,options:{method:"POST",cache:"no-cache"},path:"customer",signalType:"customer",transformer:U})},Q=()=>[s.on("authenticated",S,{eager:!0}),s.on("cart/initialized",h,{eager:!0}),s.on("cart/reset",y),s.on("cart/updated",L),s.on("checkout/initialized",()=>{i.initialized=!0})],g=new b({init:async e=>{const t=e||{};g.config.setConfig(t),A.value.data||await T()},listeners:Q}),_=g.config,h=async e=>{if(!e)i.cartId=null,l.value={pending:!1,data:null},s.emit("checkout/initialized",null);else{i.cartId=e.id;const t=await c();s.emit("checkout/initialized",t||null)}},y=()=>{i.cartId=null,l.value={pending:!1,data:null}},L=async e=>{if(!i.initialized){await h(e);return}if(e===null){y();return}i.cartId===null?(i.cartId=e.id,await c()):i.cartId===e.id&&await c()};export{ee as a,w as b,S as c,K as d,_ as e,h as f,c as g,g as i,y as r,L as s,F as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsxs as
|
|
3
|
+
import{jsxs as k,Fragment as M,jsx as t}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Skeleton as A,SkeletonRow as L,Price as g}from"@dropins/tools/components.js";/* empty css */import{VComponent as w,classes as I}from"@dropins/tools/lib.js";import{Text as l,useText as z}from"@dropins/tools/i18n.js";import{useState as B,useEffect as x}from"@dropins/tools/preact-hooks.js";/* empty css */import{a as G,T as C}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import{events as f}from"@dropins/tools/event-bus.js";import"@dropins/tools/signals.js";const P=({estimated:e=!1,price:o,priceExclTax:d,taxExcluded:p=!1,taxIncluded:a=!1})=>k(M,{children:[t("span",{className:"checkout-estimate-shipping__label",children:e?t(l,{id:"Checkout.EstimateShipping.estimated"}):t(l,{id:"Checkout.EstimateShipping.label"})}),t(w,{node:o,className:"checkout-estimate-shipping__price"}),a&&t("span",{"data-testid":"shipping-tax-included",className:I(["checkout-estimate-shipping__caption"]),children:t(l,{id:"Checkout.EstimateShipping.withTaxes"})}),p&&k("span",{"data-testid":"shipping-tax-included-excluded",className:I(["checkout-estimate-shipping__caption"]),children:[d," ",t(l,{id:"Checkout.EstimateShipping.withoutTaxes"})]})]}),U=()=>t(A,{"data-testid":"estimate-shipping-skeleton",children:t(L,{size:"xsmall"})}),W=()=>{const[e,o]=B(),d=e!==void 0,p=(e==null?void 0:e.amount.value)===0,{data:a,pending:_}=G.value,y=_||a===void 0,T=a==null?void 0:a.shoppingCartDisplaySetting.shipping,D=T===C.INCLUDING_EXCLUDING_TAX,E=T===C.INCLUDING_TAX,S=z({freeShipping:"Checkout.EstimateShipping.freeShipping",taxToBeDetermined:"Checkout.EstimateShipping.taxToBeDetermined"});x(()=>{const i=f.on("shipping/estimate",n=>{const s=n.shippingMethod,{amount:c,amountExclTax:r,amountInclTax:m}=s;o({estimated:!0,amount:c,amountExclTax:r,amountInclTax:m})},{eager:!0});return()=>{i==null||i.off()}},[]),x(()=>{const i=f.on("checkout/initialized",n=>{var u,h;const s=(h=(u=n==null?void 0:n.shippingAddresses)==null?void 0:u[0])==null?void 0:h.selectedShippingMethod;if(!s)return;const{amount:c,amountExclTax:r,amountInclTax:m}=s;o({estimated:!1,amount:c,amountExclTax:r,amountInclTax:m})},{eager:!0});return()=>{i==null||i.off()}},[]),x(()=>{const i=f.on("checkout/updated",n=>{var u,h;const s=(h=(u=n==null?void 0:n.shippingAddresses)==null?void 0:u[0])==null?void 0:h.selectedShippingMethod;if(!s)return;const{amount:c,amountExclTax:r,amountInclTax:m}=s;o({estimated:!1,amount:c,amountExclTax:r,amountInclTax:m})},{eager:!0});return()=>{i==null||i.off()}},[]);const N=()=>p?t("span",{"data-testId":"free-shipping",children:S.freeShipping}):E&&(e!=null&&e.amountInclTax)?t(g,{"data-testid":"shipping",amount:e.amountInclTax.value,currency:e.amountInclTax.currency}):t(g,{"data-testid":"shipping",amount:e==null?void 0:e.amount.value,currency:e==null?void 0:e.amount.currency}),v=()=>e!=null&&e.amountExclTax?t(g,{"data-testid":"shipping-excluding-tax",amount:e.amountExclTax.value,currency:e.amountExclTax.currency}):t("span",{children:S.taxToBeDetermined});return t("div",{"data-testid":"estimate-shipping",className:"checkout-estimate-shipping",children:!d||y?t(U,{}):t(P,{estimated:e.estimated,price:N(),taxExcluded:D&&!p,taxIncluded:E&&!p,priceExclTax:v()})})};export{W as EstimateShipping,W as default};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-checkout", "version": "0.1.0-
|
|
1
|
+
{"name": "@dropins/storefront-checkout", "version": "0.1.0-alpha53", "@dropins/tools": "~0.35.0"}
|
package/utils/index.d.ts
CHANGED
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
+
export * from './convertCase';
|
|
17
18
|
export * from './getDisplayName';
|
|
18
19
|
export * from './isEmpty';
|
|
19
20
|
export * from './isUnexpectedError';
|
|
20
|
-
export * from './refetchEstimatedShippingMethods';
|
|
21
|
-
export * from './convertCase';
|
|
22
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,18 +0,0 @@
|
|
|
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 './refetchEstimatedShippingMethods';
|
|
18
|
-
//# sourceMappingURL=index.d.ts.map
|