@dropins/storefront-checkout 1.0.0-beta1 → 1.0.0-beta2
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/getStoreConfig/getStoreConfig.d.ts +1 -1
- package/api/index.d.ts +1 -0
- package/api/utils/dispatchApiCall.d.ts +0 -4
- package/api.js +4 -4
- package/chunks/errors.js +3 -0
- package/chunks/setBillingAddress.js +3 -3
- package/chunks/setGuestEmailOnCart.js +4 -4
- package/chunks/setPaymentMethod.js +3 -3
- package/chunks/setShippingMethods.js +2 -2
- package/chunks/store-config.js +1 -1
- package/chunks/synchronizeCheckout.js +7 -7
- package/chunks/transform-store-config.js +12 -0
- package/chunks/withConditionalRendering.js +1 -1
- package/containers/BillToShippingAddress.js +1 -1
- package/containers/EstimateShipping.js +1 -1
- package/containers/LoginForm.js +1 -1
- package/containers/MergedCartBanner.js +1 -1
- package/containers/PaymentMethods.js +1 -1
- package/containers/PlaceOrder.js +1 -1
- package/containers/ShippingMethods.js +1 -1
- package/lib/state.d.ts +4 -16
- package/package.json +1 -1
- package/render.js +1 -1
- package/signals/index.d.ts +0 -1
- package/chunks/fetch-graphql.js +0 -12
- package/signals/StoreConfigSignal.d.ts +0 -7
|
@@ -2,5 +2,5 @@ import { StoreConfig } from '../../data/models';
|
|
|
2
2
|
|
|
3
3
|
export declare const DEFAULT_COUNTRY = "US";
|
|
4
4
|
export declare const STORE_CONFIG_DEFAULTS: StoreConfig;
|
|
5
|
-
export declare const getStoreConfig: () => Promise<StoreConfig
|
|
5
|
+
export declare const getStoreConfig: () => Promise<StoreConfig>;
|
|
6
6
|
//# sourceMappingURL=getStoreConfig.d.ts.map
|
package/api/index.d.ts
CHANGED
|
@@ -14,10 +14,6 @@ declare const signalTypes: {
|
|
|
14
14
|
pending: boolean;
|
|
15
15
|
data?: import('../../data/models/shipping-method').ShippingMethod[] | undefined;
|
|
16
16
|
}>;
|
|
17
|
-
storeConfig: import('@preact/signals-core').Signal<{
|
|
18
|
-
data?: import('../../data/models/store-config').StoreConfig | undefined;
|
|
19
|
-
pending: boolean;
|
|
20
|
-
}>;
|
|
21
17
|
};
|
|
22
18
|
type SignalTypesType = typeof signalTypes;
|
|
23
19
|
type SignalTypesKeys = keyof SignalTypesType;
|
package/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{t as
|
|
3
|
+
import{d as p,t as f,a as _,b as m}from"./chunks/synchronizeCheckout.js";import{e as k,c as z,g as Q,f as R,i as K,h as P,r as j,s as L}from"./chunks/synchronizeCheckout.js";import{M as l,a as A,b as C}from"./chunks/errors.js";import{F as J,I as V,e as W,c as X,d as Z,U as tt}from"./chunks/errors.js";import{s as d}from"./chunks/store-config.js";import{g as et}from"./chunks/store-config.js";import{i as S}from"./chunks/transform-store-config.js";import{D as rt,S as at,h as nt,j as ot,k as pt,r as dt,d as ct,f as gt,g as ht}from"./chunks/transform-store-config.js";import"./chunks/ServerErrorSignal.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import{i as lt,s as ut}from"./chunks/setGuestEmailOnCart.js";import{a as y}from"./chunks/setBillingAddress.js";import{s as _t}from"./chunks/setBillingAddress.js";import{s as Ct}from"./chunks/setPaymentMethod.js";import{CHECKOUT_DATA_FRAGMENT as M}from"./fragments.js";import{s as yt}from"./chunks/setShippingMethods.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const I=`
|
|
4
4
|
mutation estimateShippingMethods(
|
|
5
5
|
$cartId: String!
|
|
6
6
|
$address: EstimateAddressInput!
|
|
@@ -26,7 +26,7 @@ import{t as _,a as f,b as h}from"./chunks/synchronizeCheckout.js";import{d as k,
|
|
|
26
26
|
error_message
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
`,N=async
|
|
29
|
+
`,N=async r=>{var h;const s=d.cartId,{criteria:a}=r||{},{country_code:e,region_id:t,region_name:i,zip:n}=a||{},o=e||((h=d.config)==null?void 0:h.defaultCountry);if(!s)throw new l;if(!o)throw new A;const c=typeof t=="string"?parseInt(t,10):t,g=t||i?{...c&&{region_id:c},...i&&{region_code:i}}:void 0,u={country_code:o,...n&&{postcode:n},...g&&{region:g}};return await p({type:"mutation",query:I,options:{variables:{cartId:s,address:u}},path:"estimateShippingMethods",signalType:"estimateShippingMethods",transformer:f})},T=`
|
|
30
30
|
mutation setShippingAddress($input: SetShippingAddressesOnCartInput!) {
|
|
31
31
|
setShippingAddressesOnCart(input: $input) {
|
|
32
32
|
cart {
|
|
@@ -35,5 +35,5 @@ import{t as _,a as f,b as h}from"./chunks/synchronizeCheckout.js";import{d as k,
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
${
|
|
39
|
-
`,q=async({address:
|
|
38
|
+
${M}
|
|
39
|
+
`,q=async({address:r,customerAddressId:s,pickupLocationCode:a})=>{const e=d.cartId;if(!e)throw new l;const t={cart_id:e,shipping_addresses:[]};if(s)t.shipping_addresses.push({customer_address_id:s});else if(a)t.shipping_addresses.push({pickup_location_code:a});else{if(!r)throw new C;t.shipping_addresses.push({address:_(r)})}const i=await p({type:"mutation",query:T,options:{variables:{input:t}},path:"setShippingAddressesOnCart.cart",queueName:"cartUpdate",signalType:"cart",transformer:m});return S.value?await p({type:"mutation",query:y,options:{variables:{input:{cart_id:e,billing_address:{same_as_shipping:!0}}}},path:"setBillingAddressOnCart.cart",queueName:"cartUpdate",signalType:"cart",transformer:m}):i};export{rt as DEFAULT_COUNTRY,J as FetchError,V as InvalidArgument,W as MissingBillingAddress,l as MissingCart,A as MissingCountry,X as MissingEmail,Z as MissingPaymentMethod,C as MissingShippinghAddress,at as STORE_CONFIG_DEFAULTS,tt as UnexpectedError,k as authenticateCustomer,z as config,N as estimateShippingMethods,nt as fetchGraphQl,Q as getCart,ot as getConfig,R as getCustomer,pt as getStoreConfig,et as getStoreConfigCache,K as initialize,P as initializeCheckout,lt as isEmailAvailable,dt as removeFetchGraphQlHeader,j as resetCheckout,_t as setBillingAddress,ct as setEndpoint,gt as setFetchGraphQlHeader,ht as setFetchGraphQlHeaders,ut as setGuestEmailOnCart,Ct as setPaymentMethod,q as setShippingAddress,yt as setShippingMethodsOnCart,L as synchronizeCheckout};
|
package/chunks/errors.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Copyright 2024 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
class n extends Error{constructor(e){super(e.map(t=>t.message).join(" ")),this.name="FetchError"}}class r extends Error{constructor(e){super(e),this.name="InvalidArgument"}}class i extends Error{constructor(e){super(e),this.name="UnexpectedError"}}class a extends r{constructor(){super("Cart ID is required")}}class c extends r{constructor(){super("Email is required")}}class o extends r{constructor(){super("Payment method code is required")}}class d extends r{constructor(){super("Shipping address is required")}}class u extends r{constructor(){super("Billing address is required")}}class l extends r{constructor(){super("Country Code is required")}}export{n as F,r as I,a as M,i as U,l as a,d as b,c,o as d,u as e};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{
|
|
3
|
+
import{M as e,e as o}from"./errors.js";import{CHECKOUT_DATA_FRAGMENT as d}from"../fragments.js";import{a as l,d as p,b as u}from"./synchronizeCheckout.js";import{s as m}from"./store-config.js";import"./transform-store-config.js";import"./ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const c=`
|
|
4
4
|
mutation setBillingAddress($input: SetBillingAddressOnCartInput!) {
|
|
5
5
|
setBillingAddressOnCart(input: $input) {
|
|
6
6
|
cart {
|
|
@@ -9,5 +9,5 @@ import{s as e,M as d,f as o,d as l}from"./fetch-graphql.js";import{CHECKOUT_DATA
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
${
|
|
13
|
-
`,
|
|
12
|
+
${d}
|
|
13
|
+
`,b=async({address:i,customerAddressId:t,sameAsShipping:s=!1,useForShipping:n=!1})=>{const r=m.cartId;if(!r)throw new e;const a={cart_id:r,billing_address:{same_as_shipping:s,use_for_shipping:n}};if(!s&&t&&(a.billing_address.customer_address_id=t),!s&&!t){if(!i)throw new o;a.billing_address.address=l(i)}return await p({options:{variables:{input:a}},path:"setBillingAddressOnCart.cart",query:c,queueName:"cartUpdate",signalType:"cart",transformer:u,type:"mutation"})};export{c as a,b as s};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{
|
|
3
|
+
import{s as r}from"./store-config.js";import{h as e}from"./transform-store-config.js";import"./ServerErrorSignal.js";import{c as s,M as l}from"./errors.js";import{j as o,d as m,b as n}from"./synchronizeCheckout.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import{CHECKOUT_DATA_FRAGMENT as c}from"../fragments.js";const u=a=>!!(a!=null&&a.is_email_available),p=`
|
|
4
4
|
query isEmailAvailable($email: String!) {
|
|
5
5
|
isEmailAvailable(email: $email) {
|
|
6
6
|
is_email_available
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
`,E=a=>{if(!(!a||a.length===0))throw Error(a.map(t=>t.message).join(" "))},
|
|
9
|
+
`,E=a=>{if(!(!a||a.length===0))throw Error(a.map(t=>t.message).join(" "))},g=async a=>{if(!a)throw new s;const{data:t,errors:i}=await e(p,{method:"GET",cache:"no-cache",variables:{email:a}}).catch(o);return i&&E(i),u(t.isEmailAvailable)},h=`
|
|
10
10
|
mutation setGuestEmail($cartId: String!, $email: String!) {
|
|
11
11
|
setGuestEmailOnCart(input: { cart_id: $cartId, email: $email }) {
|
|
12
12
|
cart {
|
|
@@ -15,5 +15,5 @@ import{c as e,j as r,m as s,s as l,M as o,d as n}from"./fetch-graphql.js";import
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
${
|
|
19
|
-
`,
|
|
18
|
+
${c}
|
|
19
|
+
`,w=async a=>{const t=r.cartId;if(!t)throw new l;return await m({options:{variables:{cartId:t,email:a}},path:"setGuestEmailOnCart.cart",query:h,queueName:"cartUpdate",signalType:"cart",transformer:n,type:"mutation"})};export{g as i,w as s};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{
|
|
3
|
+
import{M as e,d as r}from"./errors.js";import{CHECKOUT_DATA_FRAGMENT as o}from"../fragments.js";import{d as n,b as s}from"./synchronizeCheckout.js";import{s as m}from"./store-config.js";import"./transform-store-config.js";import"./ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const i=`
|
|
4
4
|
mutation setPaymentMethod(
|
|
5
5
|
$cartId: String!
|
|
6
6
|
$paymentMethod: PaymentMethodInput!
|
|
@@ -14,5 +14,5 @@ import{s as e,M as r,e as o,d as n}from"./fetch-graphql.js";import{CHECKOUT_DATA
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
${
|
|
18
|
-
`,
|
|
17
|
+
${o}
|
|
18
|
+
`,A=async t=>{const a=m.cartId;if(!a)throw new e;if(!t)throw new r;return await n({options:{variables:{cartId:a,paymentMethod:t}},path:"setPaymentMethodOnCart.cart",query:i,queueName:"cartUpdate",signalType:"cart",transformer:s,type:"mutation"})};export{A as s};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{s as i
|
|
3
|
+
import{s as i}from"./store-config.js";import"./transform-store-config.js";import"./ServerErrorSignal.js";import{M as p}from"./errors.js";import{d as r,b as s}from"./synchronizeCheckout.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import{CHECKOUT_DATA_FRAGMENT as o}from"../fragments.js";const e=`
|
|
4
4
|
mutation setShippingMethods(
|
|
5
5
|
$cartId: String!
|
|
6
6
|
$shippingMethods: [ShippingMethodInput]!
|
|
@@ -15,4 +15,4 @@ import{s as i,M as p,d as s}from"./fetch-graphql.js";import"./store-config.js";i
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
${o}
|
|
18
|
-
`,
|
|
18
|
+
`,f=async a=>{const t=i.cartId;if(!t)throw new p;return await r({type:"mutation",query:e,queueName:"cartUpdate",options:{variables:{cartId:t,shippingMethods:a}},path:"setShippingMethodsOnCart.cart",signalType:"cart",transformer:s})};export{f as s};
|
package/chunks/store-config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
|
|
3
|
+
const I={authenticated:!1,cartId:null,initialized:!1,config:null},N=new Proxy(I,{set(t,e,n){return t[e]=n,!0},get(t,e){return t[e]}}),s=()=>N.config;var r=(t=>(t.EXCLUDING_TAX="EXCLUDING_TAX",t.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",t.INCLUDING_TAX="INCLUDING_TAX",t))(r||{});export{r as T,s as g,N as s};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{s as i
|
|
3
|
+
import{s as i}from"./store-config.js";import{b as C,h as y,c as m,e as R,k as z}from"./transform-store-config.js";import"./ServerErrorSignal.js";import{events as c}from"@dropins/tools/event-bus.js";import{merge as A,Initializer as G}from"@dropins/tools/lib.js";import{CHECKOUT_DATA_FRAGMENT as b,CUSTOMER_FRAGMENT as O}from"../fragments.js";import{F as $,M as U}from"./errors.js";const D=async(e=!1)=>{i.authenticated=e,e?await me():C.value={pending:!1,data:null}},x={cartUpdate:{requests:[]},default:{requests:[]}};function F(e,t="default"){const r=x[t];return new Promise((n,o)=>{r.requests.push(e);const a=()=>{r.requests[0]===e?e().then(n).catch(o).finally(()=>{var l;r.requests.shift(),r.requests.length===0?(l=r.onComplete)==null||l.call(r):a()}):setTimeout(a,100)};a()})}function Q(e,t){const r=x[e];r.onComplete=t}const V=["sender_email","recipient_email"];function B(e){return e.filter(t=>!t.path||!V.some(r=>{var n;return((n=t.path)==null?void 0:n.at(-1))===r}))}const v=e=>{throw e instanceof DOMException&&e.name==="AbortError"||c.emit("error",{source:"checkout",type:"network",error:e}),e},H={cart:m,customer:C,estimateShippingMethods:R};function K(e,t){return t.split(".").reduce((r,n)=>r&&r[n]!==void 0?r[n]:void 0,e)}const _={cart:null,customer:null,estimateShippingMethods:null};async function E(e){const{defaultValueOnFail:t,options:r,path:n,query:o,queueName:a,signalType:l,transformer:p,type:P}=e,s=H[l],d=Symbol();_[l]=d,s.value={...s.value,pending:!0};try{const{data:f,errors:h}=await(P==="mutation"?F(()=>y(o,r).catch(v),a):y(o,{method:"GET",cache:"no-cache",...r}).catch(v));if(h){const g=B(h);if(g.length>0)throw new $(g)}let u=K(f,n);if(u===void 0)throw new Error(`No data found at path: ${n}`);return p&&(u=p(u)),s.value={...s.value,data:u},setTimeout(()=>{s.value={...s.value,pending:_[l]===d?!1:s.value.pending}},0),u}catch(f){if(t)return s.value={pending:!1,data:t},t;if(f.name==="AbortError")return;throw s.value={...s.value,pending:!1},f}}const j=e=>e==null,L=(e,t)=>e.amount.value-t.amount.value,M=e=>!(!e||!e.method_code||!e.method_title||j(e.amount.value)||!e.amount.currency),T=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}}}),J=e=>{if(M(e))return T(e)},W=e=>{if(e)return e.filter(M).map(t=>T(t)).sort(L)},X=e=>e?!!e.code&&!!e.label:!1,Y=e=>{if(!X(e))return;const{code:t,label:r,region_id:n}=e;return n?{code:t,name:r,id:n}:{code:t,name:r}},Z=e=>{const{code:t,label:r}=e;return{value:t,label:r}},ee=e=>e?"code"in e&&"value"in e:!1,te=e=>e.filter(ee).map(t=>{const{code:r,value:n}=t;return{code:r,value:n}}),S=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:Z(e.country),customAttributes:te(e.custom_attributes),firstName:e.firstname,lastName:e.lastname,postCode:e.postcode||void 0,region:Y(e.region),street:t,telephone:e.telephone||void 0,vatId:e.vat_id||void 0,prefix:e.prefix||void 0,suffix:e.suffix||void 0,middleName:e.middlename||void 0,fax:e.fax||void 0}},re=e=>{if(e)return S(e)},ne=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:r,selected_shipping_method:n,same_as_billing:o,...a}=t;return{...S(a),availableShippingMethods:W(r),selectedShippingMethod:J(n),sameAsBilling:o}}),Ae=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,prefix:e.prefix,suffix:e.suffix,middlename:e.middleName,fax:e.fax}),ie=e=>{if(e)return{code:e.code,title:e.title}},oe=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:r,title:n}=t;return{code:r,title:n}})},se=e=>{var r,n,o;if(!e)return;const t={availablePaymentMethods:oe(e.available_payment_methods),billingAddress:re(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:ie(e.selected_payment_method),shippingAddresses:ne(e.shipping_addresses),isGuest:!i.authenticated};return A(t,(o=(n=(r=N.getConfig().models)==null?void 0:r.CartModel)==null?void 0:n.transformer)==null?void 0:o.call(n,e))},ce=e=>{var r,n,o;if(!e)return;const t={firstName:e.firstname||"",lastName:e.lastname||"",email:e.email||""};return A(t,(o=(n=(r=N.getConfig().models)==null?void 0:r.CustomerModel)==null?void 0:n.transformer)==null?void 0:o.call(n,e))},ae=`
|
|
4
4
|
query getCart($cartId: String!) {
|
|
5
5
|
cart(cart_id: $cartId) {
|
|
6
6
|
...CHECKOUT_DATA_FRAGMENT
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
${
|
|
11
|
-
`,
|
|
10
|
+
${b}
|
|
11
|
+
`,le=`
|
|
12
12
|
query getCustomerCart {
|
|
13
13
|
cart: customerCart {
|
|
14
14
|
...CHECKOUT_DATA_FRAGMENT
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
${
|
|
19
|
-
`,
|
|
18
|
+
${b}
|
|
19
|
+
`,w=async()=>{const e=i.cartId,t=i.authenticated===!1,r=t?ae:le,n=t?{cartId:e}:{};if(t&&!e)throw new U;return await E({type:"query",query:r,options:{method:"POST",cache:"no-cache",variables:n},path:"cart",signalType:"cart",transformer:se})},ue=`
|
|
20
20
|
query getCustomer {
|
|
21
21
|
customer {
|
|
22
22
|
...CUSTOMER_FRAGMENT
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
${
|
|
27
|
-
`,
|
|
26
|
+
${O}
|
|
27
|
+
`,me=async()=>{if(i.authenticated)return await E({type:"query",query:ue,options:{method:"POST",cache:"no-cache"},path:"customer",signalType:"customer",transformer:ce})},fe=()=>[c.on("authenticated",D,{eager:!0}),c.on("cart/initialized",I,{eager:!0}),c.on("cart/reset",pe),c.on("cart/updated",k)],q=new G({init:async e=>{const t=e||{};q.config.setConfig(t)},listeners:fe}),N=q.config;Q("cartUpdate",()=>{c.emit("checkout/updated",m.value.data)});const I=async e=>{if(i.initialized)return k(e);i.config||(i.config=await z());const t=e?e.id:null;i.cartId=t;const r=t?await w():null;m.value={pending:!1,data:r},i.initialized=!0,c.emit("checkout/initialized",r||null)},pe=()=>{i.cartId=null,m.value={pending:!1,data:null},c.emit("checkout/updated",null)},k=async e=>{if(!i.initialized)return I(e);const t=e?e.id:null;i.cartId=t;const r=t?await w():null;m.value={pending:!1,data:r},c.emit("checkout/updated",r||null)};export{Ae as a,se as b,N as c,E as d,D as e,me as f,w as g,I as h,q as i,v as j,pe as r,k as s,W as t};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*! Copyright 2024 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{T as a}from"./store-config.js";import{signal as t,effect as c}from"@dropins/tools/signals.js";import"./ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{FetchGraphQL as l}from"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const p=t(!0),u=t({pending:!1,data:void 0});c(()=>{var e;(e=u.value.data)!=null&&e.isVirtual&&(p.value=!1)});const T=t({pending:!1,data:void 0}),D=t({pending:!1,data:void 0}),b=t(),k=t(void 0),g=`
|
|
4
|
+
query getStoreConfig {
|
|
5
|
+
storeConfig {
|
|
6
|
+
default_country
|
|
7
|
+
is_guest_checkout_enabled
|
|
8
|
+
is_one_page_checkout_enabled
|
|
9
|
+
shopping_cart_display_shipping
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`,{setEndpoint:N,setFetchGraphQlHeader:U,removeFetchGraphQlHeader:I,setFetchGraphQlHeaders:L,fetchGraphQl:h,getConfig:X}=new l().getMethods(),d="US",n={defaultCountry:d,isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1,shoppingCartDisplaySetting:{shipping:a.EXCLUDING_TAX}},v=async()=>h(g,{method:"GET",cache:"no-cache"}).then(({errors:e,data:s})=>e?n:_(s.storeConfig));function f(e){switch(e){case 1:return a.EXCLUDING_TAX;case 2:return a.INCLUDING_TAX;case 3:return a.INCLUDING_EXCLUDING_TAX;default:return a.EXCLUDING_TAX}}function _(e){if(!e)return n;const{default_country:s,is_guest_checkout_enabled:i,is_one_page_checkout_enabled:o,shopping_cart_display_shipping:r}=e;return{defaultCountry:s||n.defaultCountry,isGuestCheckoutEnabled:i||n.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:o||n.isOnePageCheckoutEnabled,shoppingCartDisplaySetting:{shipping:f(r)}}}export{d as D,n as S,b as a,T as b,u as c,N as d,D as e,U as f,L as g,h,p as i,X as j,v as k,I as r,k as s};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as n}from"@dropins/tools/preact-jsx-runtime.js";import{c as d}from"./store-config.js";import"./ServerErrorSignal.js";import"./
|
|
3
|
+
import{jsx as n}from"@dropins/tools/preact-jsx-runtime.js";import{c as d}from"./transform-store-config.js";import"./ServerErrorSignal.js";import"./store-config.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";function u(i){return i.displayName||i.name||"Component"}const h=i=>{const o=u(i),a=({hideOnEmptyCart:s=!0,hideOnVirtualCart:r=!1,...e})=>{const t=d.value.data,l=t!==void 0&&(t===null||t.isEmpty),m=!!(t!=null&&t.isVirtual),c=s&&l||r&&m,p=`conditional-${o.toLowerCase()}`;return n("div",{className:p,children:!c&&n(i,{...e})})};return a.displayName=`Conditional(${o})`,a};export{h as w};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as t}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/
|
|
3
|
+
import{jsx as t}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/store-config.js";import{i as d,c as u}from"../chunks/transform-store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import{s as S}from"../chunks/setBillingAddress.js";/* empty css */import{Checkbox as b,Skeleton as f,SkeletonRow as A}from"@dropins/tools/components.js";import{c as B}from"../chunks/classes.js";import{useText as x}from"@dropins/tools/i18n.js";import{w as T}from"../chunks/withConditionalRendering.js";import{useState as v,useEffect as _}from"@dropins/tools/preact-compat.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/errors.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const w=({className:i,checked:e,loading:r,onChange:n,disabled:s})=>{const c=x({title:"Checkout.BillToShippingAddress.title"});return r?t(y,{}):t("div",{className:"checkout-bill-to-shipping-address",children:t(b,{checked:e,className:B(["checkout-bill-to-shipping-address__checkbox",i]),"data-testid":"bill-to-shipping-checkbox",disabled:s,label:c.title,name:"checkout-bill-to-shipping-address__checkbox",onChange:n})})},y=()=>t(f,{className:"bill-to-shipping-address__skeleton",children:t(A,{variant:"row",size:"small"})}),k=({onChange:i})=>{var g;const[e,r]=v(!0),n=d.value,s=u.value.data,c=u.value.pending,p=!!s,m=!!(s==null?void 0:s.billingAddress),l=(g=s==null?void 0:s.shippingAddresses)==null?void 0:g[0],h=l==null?void 0:l.sameAsBilling;return _(()=>{if(!e||!p)return;r(!1);const o=h??!m;d.value=o,i==null||i(o)},[p,m,h,e,i]),t(w,{checked:n,disabled:c,loading:e,onChange:async o=>{const a=o.target.checked;d.value=a,i==null||i(a),!e&&l&&a&&await S({sameAsShipping:!0}).catch(console.error)}})};k.displayName="BillToShippingAddressContainer";const V=T(k);export{V as BillToShippingAddress,V as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsxs as k,Fragment as
|
|
3
|
+
import{jsxs as k,Fragment as y,jsx as t}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Skeleton as v,SkeletonRow as M,Price as x}from"@dropins/tools/components.js";/* empty css */import{VComponent as A,classes as I}from"@dropins/tools/lib.js";import{Text as l,useText as w}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{s as z,T as C}from"../chunks/store-config.js";import{events as g}from"@dropins/tools/event-bus.js";import{useState as B,useEffect as f}from"@dropins/tools/preact-hooks.js";const G=({estimated:e=!1,price:a,priceExclTax:d,taxExcluded:o=!1,taxIncluded:p=!1})=>k(y,{children:[t("span",{className:"checkout-estimate-shipping__label",children:e?t(l,{id:"Checkout.EstimateShipping.estimated"}):t(l,{id:"Checkout.EstimateShipping.label"})}),t(A,{node:a,className:"checkout-estimate-shipping__price"}),p&&t("span",{"data-testid":"shipping-tax-included",className:I(["checkout-estimate-shipping__caption"]),children:t(l,{id:"Checkout.EstimateShipping.withTaxes"})}),o&&k("span",{"data-testid":"shipping-tax-included-excluded",className:I(["checkout-estimate-shipping__caption"]),children:[d," ",t(l,{id:"Checkout.EstimateShipping.withoutTaxes"})]})]}),L=()=>t(v,{"data-testid":"estimate-shipping-skeleton",children:t(M,{size:"xsmall"})}),O=()=>{const[e,a]=B(),d=e!==void 0,o=(e==null?void 0:e.amount.value)===0,p=z.config,T=p==null?void 0:p.shoppingCartDisplaySetting.shipping,_=T===C.INCLUDING_EXCLUDING_TAX,E=T===C.INCLUDING_TAX,S=w({freeShipping:"Checkout.EstimateShipping.freeShipping",taxToBeDetermined:"Checkout.EstimateShipping.taxToBeDetermined"});f(()=>{const i=g.on("shipping/estimate",n=>{const s=n.shippingMethod,{amount:c,amountExclTax:r,amountInclTax:m}=s;a({estimated:!0,amount:c,amountExclTax:r,amountInclTax:m})},{eager:!0});return()=>{i==null||i.off()}},[]),f(()=>{const i=g.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;a({estimated:!1,amount:c,amountExclTax:r,amountInclTax:m})},{eager:!0});return()=>{i==null||i.off()}},[]),f(()=>{const i=g.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;a({estimated:!1,amount:c,amountExclTax:r,amountInclTax:m})},{eager:!0});return()=>{i==null||i.off()}},[]);const D=()=>o?t("span",{"data-testId":"free-shipping",children:S.freeShipping}):E&&(e!=null&&e.amountInclTax)?t(x,{"data-testid":"shipping",amount:e.amountInclTax.value,currency:e.amountInclTax.currency}):t(x,{"data-testid":"shipping",amount:e==null?void 0:e.amount.value,currency:e==null?void 0:e.amount.currency}),N=()=>e!=null&&e.amountExclTax?t(x,{"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?t(G,{estimated:e.estimated,price:D(),taxExcluded:_&&!o,taxIncluded:E&&!o,priceExclTax:N()}):t(L,{})})};export{O as EstimateShipping,O as default};
|
package/containers/LoginForm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as e,jsxs as s,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{s as H}from"../chunks/
|
|
3
|
+
import{jsx as e,jsxs as s,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{s as H}from"../chunks/store-config.js";import{c as R,b as V}from"../chunks/transform-store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{classes as j}from"@dropins/tools/lib.js";import{i as q,s as D}from"../chunks/setGuestEmailOnCart.js";import{Field as W,Input as G,Skeleton as U,SkeletonRow as x}from"@dropins/tools/components.js";/* empty css *//* empty css */import{useText as b,Text as _}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{w as J}from"../chunks/withConditionalRendering.js";import{useState as v,useRef as K,useEffect as C}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/errors.js";import"../chunks/synchronizeCheckout.js";import"../fragments.js";const O=({value:t,error:i,hint:g,onChange:h,onBlur:o,onInvalid:u})=>{const m=b({LoginFormLabel:"Checkout.LoginForm.ariaLabel",LoginFormFloatingLabel:"Checkout.LoginForm.floatingLabel",LoginFormPlaceholder:"Checkout.LoginForm.placeholder"});return e(W,{size:"medium",error:i,hint:g,children:e(G,{"aria-label":m.LoginFormLabel,"aria-required":!0,autocomplete:"email",floatingLabel:m.LoginFormFloatingLabel,id:"customer-email",name:"customer-email",onBlur:o,onChange:h,onInvalid:u,placeholder:m.LoginFormPlaceholder,required:!0,type:"email",value:t})})},Q=({onClick:t})=>s("div",{className:"checkout-login-form__sign-in",children:[e(_,{id:"Checkout.LoginForm.account"}),e("a",{"data-testid":"sign-in-link",className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t,children:e(_,{id:"Checkout.LoginForm.signIn"})})]}),X=({className:t,customerDetails:i,email:g,error:h,hint:o,loading:u=!1,name:m,onEmailBlur:f,onEmailChange:k,onEmailInvalid:E,onSignInClick:a,onSignOutClick:F,...L})=>{const l=b({Title:"Checkout.LoginForm.title"});return u?e(Y,{}):s("div",{className:"checkout-login-form","data-testid":"checkout-login-form",children:[s("div",{className:"checkout-login-form__heading",children:[e("h2",{className:"checkout-login-form__title",children:l.Title}),i?e(Z,{onClick:d=>{d.preventDefault(),F==null||F()}}):e(Q,{onClick:d=>{d.preventDefault(),a==null||a(g)}})]}),i?s("div",{className:"checkout-login-form__customer-details",children:[e("div",{className:"checkout-login-form__customer-name",children:`${i.firstName} ${i.lastName}`}),e("div",{className:"checkout-login-form__customer-email",children:i.email})]}):e("div",{className:"checkout-login-form__content",children:s("form",{...L,className:j(["dropin-login-form__form",t]),name:m,noValidate:!0,children:[e("button",{type:"submit",disabled:!0,style:"display: none","aria-hidden":"true"}),e(O,{value:g,error:h,hint:o,onChange:k,onBlur:f,onInvalid:E})]})})]})},Y=()=>s(U,{"data-testid":"login-form-skeleton",children:[e(x,{variant:"heading",fullWidth:!0}),e(x,{size:"medium",fullWidth:!0})]}),Z=({onClick:t})=>s("p",{className:"checkout-login-form__sign-out",children:[e(_,{id:"Checkout.LoginForm.switch"}),e("a",{className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t,children:e(_,{id:"Checkout.LoginForm.signOut"})})]}),S={EMAIL:/^[a-z0-9,!#$%&'*+/=?^_`{|}~-]+(\.[a-z0-9,!#$%&'*+/=?^_`{|}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i},N=t=>S.EMAIL.test(t),ee=1e3,y=({onSignInClick:t,onSignOutClick:i,initialData:g,...h})=>{const[o,u]=v(""),[m,f]=v(""),[k,E]=v(!0),[a,F]=v(!0),L=K(""),l=R.value.data,d=(l==null?void 0:l.email)||"",p=V.value.data,c=b({LoginFormInvalidEmailError:"Checkout.LoginForm.invalidEmailError",LoginFormMissingEmailError:"Checkout.LoginForm.missingEmailError",LoginFormEmailExistsAlreadyHaveAccount:"Checkout.LoginForm.emailExists.alreadyHaveAccount",LoginFormEmailExistsSignInButton:"Checkout.LoginForm.emailExists.signInButton",LoginFormEmailExistsForFasterCheckout:"Checkout.LoginForm.emailExists.forFasterCheckout"}),A=r=>r.valid?"":r.valueMissing?c.LoginFormMissingEmailError:c.LoginFormInvalidEmailError,B=r=>N(r)?"":r===""?c.LoginFormMissingEmailError:c.LoginFormInvalidEmailError,M=r=>{const n=r.target;u(n.value),f(""),E(!0)},T=r=>{const n=r.target;f(B(n.value))},z=r=>{const n=r.target;f(A(n.validity))};C(()=>{!a||!l||(F(!1),u(l.email||""))},[l,a]),C(()=>{if(a||H.authenticated)return;const r=setTimeout(()=>{!N(o)||o===L.current||(L.current=o,q(o).then(n=>{E(n),d!==o&&D(o).catch(console.error)}).catch(n=>{console.error(n),E(!0)}))},ee);return()=>{r&&clearTimeout(r)}},[d,o,a]);const I=k?"":s(w,{children:[c.LoginFormEmailExistsAlreadyHaveAccount," ",e("a",{href:"#",onClick:r=>{r.preventDefault(),t==null||t(o)},children:c.LoginFormEmailExistsSignInButton})," ",c.LoginFormEmailExistsForFasterCheckout]}),$=r=>{t==null||t(N(r)?r:"")},P=p?{firstName:p.firstName,lastName:p.lastName,email:p.email}:void 0;return e(X,{...h,customerDetails:P,email:o,error:m,hint:I,loading:a,onEmailBlur:T,onEmailChange:M,onEmailInvalid:z,onSignInClick:$,onSignOutClick:i})};y.displayName="LoginFormContainer";const ke=J(y);export{ke as LoginForm,ke as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as e}from"@dropins/tools/preact-jsx-runtime.js";import{AlertBanner as g,Icon as u}from"@dropins/tools/components.js";import{c as h}from"../chunks/classes.js";import{events as B}from"@dropins/tools/event-bus.js";import*as l from"@dropins/tools/preact-compat.js";import{useState as I,useEffect as M}from"@dropins/tools/preact-compat.js";import{w as v}from"../chunks/withConditionalRendering.js";import{useText as w,Text as x}from"@dropins/tools/i18n.js";import"../chunks/store-config.js";import"
|
|
3
|
+
import{jsx as e}from"@dropins/tools/preact-jsx-runtime.js";import{AlertBanner as g,Icon as u}from"@dropins/tools/components.js";import{c as h}from"../chunks/classes.js";import{events as B}from"@dropins/tools/event-bus.js";import*as l from"@dropins/tools/preact-compat.js";import{useState as I,useEffect as M}from"@dropins/tools/preact-compat.js";import{w as v}from"../chunks/withConditionalRendering.js";import{useText as w,Text as x}from"@dropins/tools/i18n.js";import"../chunks/transform-store-config.js";import"../chunks/store-config.js";import"@dropins/tools/signals.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const H=t=>l.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 12C0 5.37931 5.37931 0 12 0C18.6207 0 24 5.37931 24 12C24 18.6207 18.6207 24 12 24C5.37931 24 0 18.6207 0 12ZM11.8885 5.06101C11.1405 5.06101 10.5357 5.66579 10.5357 6.4138V6.57295C10.5835 7.27321 11.1882 7.81433 11.8885 7.76658H12.0795C12.7797 7.70292 13.289 7.09815 13.2413 6.4138C13.2413 5.66579 12.6365 5.06101 11.8885 5.06101ZM13.1935 16.8223H14.1007C14.2599 16.8223 14.4031 16.9655 14.4031 17.1247V17.7294C14.4031 17.9045 14.2599 18.0318 14.1007 18.0318H9.8832C9.70813 18.0318 9.58081 17.8886 9.58081 17.7294V17.1247C9.58081 16.9496 9.72405 16.8223 9.8832 16.8223H10.7904V10.7905H9.8832C9.70813 10.7905 9.58081 10.6472 9.58081 10.4881V9.88329C9.58081 9.70823 9.72405 9.58091 9.8832 9.58091H12.5888C12.923 9.58091 13.1935 9.85146 13.1935 10.1857V16.8223Z",fill:"currentColor"})),C=({className:t,initialData:V,...c})=>{const[r,a]=I(0),i=w({mergedCartBannerItems:e(x,{id:"Checkout.MergedCartBanner.items",fields:{count:r},plural:r})});M(()=>{const n=B.on("cart/merged",o=>{var m;const s=(m=o==null?void 0:o.oldCartItems)==null?void 0:m.reduce((f,p)=>f+p.quantity,0);s>0&&a(s)});return()=>{n==null||n.off()}},[]);const d=()=>{a(0)};return r?e(g,{...c,"aria-label":i.mergedCartBannerItems,className:h(["checkout__banner",t]),"data-testid":"merged-cart-banner",icon:e(u,{source:H}),message:e("span",{children:i.mergedCartBannerItems}),onDismiss:d,variant:"neutral"}):null};C.displayName="MergedCartBannerContainer";const A=v(C);export{A as MergedCartBanner,A as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as n,jsxs as v,Fragment as D}from"@dropins/tools/preact-jsx-runtime.js";import{s as $}from"../chunks/
|
|
3
|
+
import{jsx as n,jsxs as v,Fragment as D}from"@dropins/tools/preact-jsx-runtime.js";import{s as $}from"../chunks/store-config.js";import{c as H,a as y}from"../chunks/transform-store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{classes as S,Slot as T}from"@dropins/tools/lib.js";import{s as B}from"../chunks/setPaymentMethod.js";/* empty css */import{IllustratedMessage as U,Icon as Z,ProgressSpinner as F,ToggleButton as q,Skeleton as G,SkeletonRow as g}from"@dropins/tools/components.js";import*as k from"@dropins/tools/preact-compat.js";import{useState as w,useCallback as N,useEffect as E}from"@dropins/tools/preact-compat.js";import{useText as J}from"@dropins/tools/i18n.js";import{w as K}from"../chunks/withConditionalRendering.js";import{useRef as Q}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/errors.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const X=e=>k.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},k.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),k.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),k.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),Y=({code:e,loading:r,selected:o,onChange:d,title:h})=>n(q,{className:"checkout-payment-methods__method",label:h,name:"payment-method",value:e,selected:o,onChange:d,busy:r}),ee=({className:e,paymentMethodContent:r,loading:o=!1,initializing:d=!1,onChange:h=()=>{},options:c,selection:M})=>{const a=J({Title:"Checkout.PaymentMethods.title",EmptyState:"Checkout.PaymentMethods.emptyState"});return d?n(te,{}):v("div",{className:S(["checkout-payment-methods",e]),children:[n("h2",{className:"checkout-payment-methods__title",children:a.Title}),!o&&c.length===0&&n(U,{icon:n(Z,{source:X}),message:n("p",{children:a.EmptyState})}),v("div",{className:S(["checkout-payment-methods__wrapper"]),children:[o&&n(F,{className:"checkout-payment-methods__spinner"}),n("div",{className:S(["checkout-payment-methods__methods",["checkout-payment-methods--loading",o],["checkout-payment-methods--full-width",c.length%2!==0]]),children:c==null?void 0:c.map(i=>n(Y,{code:i.code,onChange:h,selected:i.code===M,title:i.title},i.code))}),r&&n("div",{className:"checkout-payment-methods__content",children:r})]})]})},te=()=>v(G,{"data-testid":"payment-methods-skeleton",children:[n(g,{variant:"heading",size:"medium"}),n(g,{variant:"empty",size:"medium"}),n(g,{size:"xlarge",fullWidth:!0}),n(g,{size:"xlarge",fullWidth:!0})]}),V={free:e=>{const r=document.createElement("div");r.innerText="",e.replaceHTML(r)},checkmo:e=>{const r=document.createElement("div");r.innerText="",e.replaceHTML(r)}},ne=(e,r)=>{const o=Q(e);return r(o.current,e)||(o.current=e),o.current},W=({slots:e,setOnChange:r={}})=>{var _,L;const[o]=w(r),[d,h]=w(V),[c,M]=w(!0),a=H.value.data,i=!!H.value.data,O=H.value.pending,j=(a==null?void 0:a.isVirtual)??!1,z=(_=a==null?void 0:a.shippingAddresses)==null?void 0:_[0],A=(a==null?void 0:a.availablePaymentMethods)||[],m=(L=a==null?void 0:a.selectedPaymentMethod)==null?void 0:L.code,b=j?!0:!!z,l=ne(A,(t,s)=>t.length!==s.length?!1:t.every((p,C)=>p.code===s[C].code)),u=N(t=>{y.value=t,!(!t||!b)&&t!==m&&o[t]!==!1&&B({code:t}).catch(console.error)},[b,m,o]);E(()=>{if(!i)return;if(!!!(l!=null&&l.length)){u(void 0);return}const s=l[0].code;if(!m){u(s);return}const p=l.some(C=>C.code===m);u(p?m:s)},[l,i,m,u]);const I=t=>{u(t)},x=N((t,s)=>{if(!t){console.warn("Payment method handler is ignored because it has no code");return}if(!s){console.warn("Payment method handler is ignored because it is empty");return}h(p=>({...p,[t]:s}))},[]);E(()=>{e!=null&&e.Handlers&&Object.entries(e.Handlers).forEach(([t,s])=>{x(t,s)})},[x,e==null?void 0:e.Handlers]);const f=e!=null&&e.Main?n(T,{name:"PaymentMethods",slot:e==null?void 0:e.Main,context:{replaceHTML(t){this.replaceWith(t),M(!1)}}}):null,P=y.value?d[y.value]:null,R=P?n(T,{name:"PaymentMethodContent",slot:P,context:{cartId:$.cartId||"",replaceHTML(t){this.replaceWith(t)}}},P):void 0;return E(()=>{!c&&d!=V&&console.warn("Payment method handlers you have added are ignored because the default content has been replaced")},[c,d]),v(D,{children:[f&&n(f.type,{ref:f.ref,...f.props}),c&&n(ee,{initializing:i===!1,loading:i&&O,onChange:I,options:l,paymentMethodContent:R,selection:y.value})]})};W.displayName="PaymentMethodsContainer";const Pe=K(W);export{Pe as PaymentMethods,Pe as default};
|
package/containers/PlaceOrder.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as a}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Button as x}from"@dropins/tools/components.js";import{classes as E}from"@dropins/tools/lib.js";import{Text as g,useText as v}from"@dropins/tools/i18n.js";import{w as y}from"../chunks/withConditionalRendering.js";import{
|
|
3
|
+
import{jsx as a}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Button as x}from"@dropins/tools/components.js";import{classes as E}from"@dropins/tools/lib.js";import{Text as g,useText as v}from"@dropins/tools/i18n.js";import{w as y}from"../chunks/withConditionalRendering.js";import{s as P}from"../chunks/store-config.js";import{c as S,a as b}from"../chunks/transform-store-config.js";import{s as U}from"../chunks/ServerErrorSignal.js";import{U as I}from"../chunks/errors.js";import{events as w}from"@dropins/tools/event-bus.js";import{useState as N,useCallback as m,useEffect as T}from"@dropins/tools/preact-compat.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const z=r=>r instanceof TypeError||r instanceof I,D=({className:r,disabled:t=!1,onClick:o})=>a("div",{className:E(["checkout-place-order",r]),children:a(x,{className:"checkout-place-order__button","data-testid":"place-order-button",disabled:t,onClick:o,size:"medium",type:"submit",variant:"primary",children:a(g,{id:"Checkout.PlaceOrder.button"})},"placeOrder")}),l=({disabled:r=!1,handleValidation:t,handlePlaceOrder:o,...u})=>{const[d,p]=N(!1),{data:f,pending:O}=S.value,k=!!f,s=v({CheckoutUnexpectedError:"Checkout.ServerError.unexpected"}),n=m(e=>{U.value=z(e)?s.CheckoutUnexpectedError:e.message},[s]),h=m(async()=>{try{if(!(t?t():!0))return;await o({cartId:P.cartId||"",code:b.value||""})}catch(e){n(e)}},[t,o,n]);return T(()=>{const e=w.on("cart/initialized",c=>{const C=(c==null?void 0:c.items)||[];p(C.some(i=>i.outOfStock||i.insufficientQuantity))},{eager:!0});return()=>{e==null||e.off()}},[]),a(D,{...u,onClick:h,disabled:r||!k||O||d})};l.displayName="PlaceOrderContainer";const K=y(l);export{K as PlaceOrder,K as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2024 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as n,jsxs as v,Fragment as T}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/
|
|
3
|
+
import{jsx as n,jsxs as v,Fragment as T}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/store-config.js";import{s as k,e as S,c as W}from"../chunks/transform-store-config.js";import"../chunks/ServerErrorSignal.js";import{events as H}from"@dropins/tools/event-bus.js";import{classes as x,Slot as z}from"@dropins/tools/lib.js";import{s as B}from"../chunks/setShippingMethods.js";/* empty css */import{IllustratedMessage as R,Icon as V,ProgressSpinner as A,RadioButton as O,Price as P,Skeleton as D,SkeletonRow as L}from"@dropins/tools/components.js";import*as p from"@dropins/tools/preact-compat.js";import{useCallback as Z,useMemo as $,useEffect as q}from"@dropins/tools/preact-compat.js";import{useText as F}from"@dropins/tools/i18n.js";import{useState as N,useEffect as _}from"@dropins/tools/preact-hooks.js";import{w as G}from"../chunks/withConditionalRendering.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/errors.js";import"../chunks/synchronizeCheckout.js";import"../fragments.js";const J=e=>({countryCode:e.country_id,postCode:e.postcode||"",...e.region_id?{regionId:Number(e.region_id)}:{...e.region?{region:e.region}:{}}}),K=e=>({carrierCode:e.carrier.code||"",methodCode:e.code||"",amount:e.amount,amountExclTax:e.amountExclTax,amountInclTax:e.amountInclTax}),Q=e=>p.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.47266 4.90002H15.1851V10.9645H21.2495L23 12.715V17.6124H20.073",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76151 16.7898C9.76151 18.0525 8.72845 19.076 7.46582 19.076C6.20318 19.076 5.17969 18.0429 5.17969 16.7803C5.17969 15.5176 6.20318 14.4941 7.46582 14.4941C8.72845 14.4941 9.75195 15.5176 9.76151 16.7803C9.76151 16.7803 9.76151 16.7803 9.76151 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8726 16.7898C19.8726 18.062 18.8491 19.0855 17.5769 19.0855C16.3047 19.0855 15.2812 18.062 15.2812 16.7898C15.2812 15.5176 16.3047 14.4941 17.5769 14.4941C18.8491 14.4941 19.8726 15.5176 19.8726 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),U=({className:e,isLoading:t=!1,onSelectionChange:s=()=>{},options:c,selection:l,...u})=>{const i=F({Title:"Checkout.ShippingMethods.title",EmptyState:"Checkout.ShippingMethods.emptyState"});return c===void 0?n(X,{}):v("div",{...u,className:x(["checkout-shipping-methods",e]),children:[n("h3",{className:"checkout-shipping-methods__title",children:i.Title}),!t&&c.length===0&&n(R,{icon:n(V,{source:Q}),message:n("p",{children:i.EmptyState})}),v("div",{className:x(["checkout-shipping-methods__content"]),children:[t&&n(A,{className:"checkout-shipping-methods__spinner"}),n("div",{className:x(["checkout-shipping-methods__options",["checkout-shipping-methods__options--loading",t]]),children:c.map(o=>n(O,{"data-testid":"shipping-method-radiobutton","aria-busy":t,id:o.value,name:"shipping-method",className:"checkout-shipping-methods__method",label:v(T,{children:[n(P,{amount:o.amount.value,currency:o.amount.currency})," ",n("span",{children:o.carrier.title})]}),description:o.title,value:o.value,checked:(l==null?void 0:l.value)===o.value,onChange:()=>s(o)},o.value))})]})]})},X=()=>v(D,{"data-testid":"shipping-methods-skeleton",children:[n(L,{variant:"heading",size:"small"}),n(L,{variant:"empty",size:"small"}),n(L,{size:"medium",fullWidth:!0}),n(L,{size:"medium",fullWidth:!0})]});function Y(){var a;const[e,t]=N(),[s,c]=N();_(()=>{H.on("checkout/estimate-shipping-address",({address:E,isValid:M})=>{t({address:E,isValid:M})})},[]),_(()=>{c(k.value)},[k.value]),_(()=>{S.value.pending?c(void 0):c(k.value)},[S.value.pending]);const{country_id:l,region_id:u,region:i,postcode:o}=(e==null?void 0:e.address)||{},r=!!e,g=W.value.data,C=!!((a=g==null?void 0:g.shippingAddresses)!=null&&a[0]),d=e==null?void 0:e.isValid;_(()=>{C||d||!s||!r||H.emit("shipping/estimate",{address:J({country_id:l,region_id:u,region:i,postcode:o}),shippingMethod:K(s)})},[s,l,u,i,o,r,C,d])}const j=(e,t)=>e.code===t.code&&e.carrier.code===t.carrier.code;function ee({preSelectedMethod:e,onShippingMethodSelect:t}){const s=W.value.data,c=W.value.pending,l=S.value.data,u=S.value.pending,i=k.value,o=s==null?void 0:s.shippingAddresses,r=o==null?void 0:o[0],g=!!r,C=r==null?void 0:r.availableShippingMethods,d=r==null?void 0:r.selectedShippingMethod,a=C||l,E=Z(m=>{if(!g)return;const f={method_code:m.code,carrier_code:m.carrier.code};B([f]).catch(b=>{console.error("Setting shipping methods on cart failed:",b)})},[g]),M=m=>{k.value=m,t==null||t(m)},h=$(()=>{if(!(a!=null&&a.length))return;const m=a[0],f=i||d;return f?a.some(w=>j(w,f))?f:m:a.find(y=>y.carrier.code===(e==null?void 0:e.carrierCode)&&y.code===(e==null?void 0:e.methodCode))||m},[i,d,a,e]);return q(()=>{h&&((!i||!j(h,i))&&(k.value=h,t==null||t(h)),(!d||!j(h,d))&&E(h))},[h,i,d,E,t]),{isLoading:c||u,options:a,selection:h,onSelectionChange:M}}const I=({preSelectedMethod:e,shippingMethodsSlot:t,onShippingMethodSelect:s,initialData:c,...l})=>{const{isLoading:u,options:i,selection:o,onSelectionChange:r}=ee({preSelectedMethod:e,onShippingMethodSelect:s});return Y(),v(T,{children:[n(U,{...l,isLoading:u,onSelectionChange:r,options:i,selection:o}),!u&&t&&n(z,{name:"ShippingMethods",slot:t})]})};I.displayName="ShippingMethodsContainer";const Ce=G(I);export{Ce as ShippingMethods,Ce as default};
|
package/lib/state.d.ts
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
*******************************************************************/
|
|
1
|
+
import { StoreConfig } from '../data/models';
|
|
2
|
+
|
|
17
3
|
type State = {
|
|
18
4
|
authenticated: boolean;
|
|
19
5
|
cartId: string | null;
|
|
20
6
|
initialized: boolean;
|
|
7
|
+
config: StoreConfig | null;
|
|
21
8
|
};
|
|
22
9
|
export declare const state: State;
|
|
10
|
+
export declare const getStoreConfigCache: () => StoreConfig | null;
|
|
23
11
|
export {};
|
|
24
12
|
//# sourceMappingURL=state.d.ts.map
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-checkout", "version": "1.0.0-
|
|
1
|
+
{"name": "@dropins/storefront-checkout", "version": "1.0.0-beta2", "@dropins/tools": "~0.37.0"}
|
package/render.js
CHANGED
|
@@ -6,4 +6,4 @@ All Rights Reserved. */
|
|
|
6
6
|
.checkout-place-order{display:grid;padding-bottom:var(--spacing-big)}.checkout-place-order__button{align-self:flex-end;justify-self:flex-end}@media only screen and (min-width:320px) and (max-width: 768px){.checkout-place-order{background-color:var(--color-neutral-200);padding:var(--spacing-medium) var(--spacing-medium) var(--spacing-big) var(--spacing-medium)}.checkout-place-order__button{align-self:center;justify-self:stretch}}
|
|
7
7
|
.checkout-payment-methods__title{color:var(--color-neutral-800);font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-payment-methods__wrapper{position:relative;display:grid}.checkout-payment-methods__methods{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium)}.checkout-payment-methods__content>div[data-slot=PaymentMethodSlot]:not(:empty){margin-top:var(--spacing-medium)}.checkout-payment-methods--full-width{grid-template-columns:1fr}.checkout-payment-methods--loading{opacity:.4;pointer-events:none}.checkout-payment-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0}.checkout__content [data-slot=PaymentMethods]:empty{display:none}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-payment-methods__methods{grid-template-columns:1fr}}
|
|
8
8
|
.checkout-bill-to-shipping-address label{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);gap:0}`,{styleId:"checkout"});
|
|
9
|
-
import{jsx as f}from"@dropins/tools/preact-jsx-runtime.js";import{Render as d}from"@dropins/tools/lib.js";import"./chunks/
|
|
9
|
+
import{jsx as f}from"@dropins/tools/preact-jsx-runtime.js";import{Render as d}from"@dropins/tools/lib.js";import"./chunks/store-config.js";import"./chunks/transform-store-config.js";import"./chunks/ServerErrorSignal.js";import{events as p}from"@dropins/tools/event-bus.js";import{c as g}from"./chunks/synchronizeCheckout.js";import{UIProvider as y}from"@dropins/tools/components.js";import{useState as b,useEffect as h}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"./fragments.js";import"./chunks/errors.js";function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var S=function(r){return E(r)&&!w(r)};function E(e){return!!e&&typeof e=="object"}function w(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||M(e)}var v=typeof Symbol=="function"&&Symbol.for,j=v?Symbol.for("react.element"):60103;function M(e){return e.$$typeof===j}function A(e){return Array.isArray(e)?[]:{}}function i(e,r){return r.clone!==!1&&r.isMergeableObject(e)?a(A(e),e,r):e}function P(e,r,t){return e.concat(r).map(function(o){return i(o,t)})}function I(e,r){if(!r.customMerge)return a;var t=r.customMerge(e);return typeof t=="function"?t:a}function T(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(r){return Object.propertyIsEnumerable.call(e,r)}):[]}function l(e){return Object.keys(e).concat(T(e))}function m(e,r){try{return r in e}catch{return!1}}function C(e,r){return m(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))}function x(e,r,t){var o={};return t.isMergeableObject(e)&&l(e).forEach(function(n){o[n]=i(e[n],t)}),l(r).forEach(function(n){C(e,n)||(m(e,n)&&t.isMergeableObject(r[n])?o[n]=I(n,t)(e[n],r[n],t):o[n]=i(r[n],t))}),o}function a(e,r,t){t=t||{},t.arrayMerge=t.arrayMerge||P,t.isMergeableObject=t.isMergeableObject||S,t.cloneUnlessOtherwiseSpecified=i;var o=Array.isArray(r),n=Array.isArray(e),c=o===n;return c?o?t.arrayMerge(e,r,t):x(e,r,t):i(r,t)}a.all=function(r,t){if(!Array.isArray(r))throw new Error("first argument should be an array");return r.reduce(function(o,n){return a(o,n,t)},{})};var D=a,B=D;const L=O(B),_={title:"Checkout",LoginForm:{title:"Contact details",account:"Already have an account?",ariaLabel:"Email",invalidEmailError:"Please enter a valid email address.",missingEmailError:"Enter an email address.",emailExists:{alreadyHaveAccount:"It looks like you already have an account.",signInButton:"Sign in",forFasterCheckout:"for a faster checkout."},floatingLabel:"Email *",placeholder:"Enter your email address",signIn:"Sign In",switch:"Do you want to switch account?",signOut:"Sign Out"},ShippingMethods:{title:"Shipping options",emptyState:"This order can't be shipped to the address provided. Please review the address details you entered and make sure they're correct."},BillToShippingAddress:{title:"Bill to shipping address"},PaymentMethods:{title:"Payment",emptyState:"No payment methods available"},OutOfStock:{title:"Your cart contains items that are out of stock",message:"The following items are out of stock:",actions:{reviewCart:"Review cart",removeOutOfStock:"Remove out of stock items"},lowInventory:{one:"Last item!",many:"Only {{count}} left!"},alert:"Out of stock!"},PlaceOrder:{button:"Place Order"},ServerError:{title:"We were unable to process your order",contactSupport:"If you continue to have issues, please contact support.",unexpected:"An unexpected error occurred while processing your order. Please try again later.",button:"Try again"},EmptyCart:{title:"Your cart is empty",button:"Start shopping"},ErrorBanner:{genericMessage:"Server error detected. Please check your connection and try again."},MergedCartBanner:{items:{one:"1 item from a previous session was added to your cart. Please review your new subtotal.",many:"{{count}} items from a previous session were added to your cart. Please review your new subtotal."}},EstimateShipping:{estimated:"Estimated Shipping",freeShipping:"Free",label:"Shipping",taxToBeDetermined:"TBD",withTaxes:"Including taxes",withoutTaxes:"Excluding taxes"}},R={Checkout:_},U={default:R},k=({children:e})=>{var c;const[r,t]=b(),o=(c=g.getConfig())==null?void 0:c.langDefinitions;h(()=>{const s=p.on("locale",u=>{u!==r&&t(u)},{eager:!0});return()=>{s==null||s.off()}},[r]);const n=L(U,o??{});return f(y,{lang:r,langDefinitions:n,children:e})},X=new d(f(k,{}));export{k as Provider,X as render};
|
package/signals/index.d.ts
CHANGED
package/chunks/fetch-graphql.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/*! Copyright 2024 Adobe
|
|
2
|
-
All Rights Reserved. */
|
|
3
|
-
import{c as T,b as q,e as b,d as v,T as l}from"./store-config.js";import"./ServerErrorSignal.js";import{events as A}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import{FetchGraphQL as G}from"@dropins/tools/fetch-graphql.js";const x={authenticated:!1,cartId:null,initialized:!1},j=new Proxy(x,{set(e,t,s){return e[t]=s,!0},get(e,t){return e[t]}});class D extends Error{constructor(t){super(t.map(s=>s.message).join(" ")),this.name="FetchError"}}class i extends Error{constructor(t){super(t),this.name="InvalidArgument"}}class B extends Error{constructor(t){super(t),this.name="UnexpectedError"}}class z extends i{constructor(){super("Cart ID is required")}}class Y extends i{constructor(){super("Email is required")}}class $ extends i{constructor(){super("Payment method code is required")}}class J extends i{constructor(){super("Shipping address is required")}}class K extends i{constructor(){super("Billing address is required")}}class W extends i{constructor(){super("Country Code is required")}}const y={cartUpdate:{requests:[]},default:{requests:[]}};function k(e,t="default"){const s=y[t];return new Promise((r,a)=>{s.requests.push(e);const u=()=>{s.requests[0]===e?e().then(r).catch(a).finally(()=>{var o;s.requests.shift(),s.requests.length===0?(o=s.onComplete)==null||o.call(s):u()}):setTimeout(u,100)};u()})}function Z(e,t){const s=y[e];s.onComplete=t}const w=["sender_email","recipient_email"];function I(e){return e.filter(t=>!t.path||!w.some(s=>{var r;return((r=t.path)==null?void 0:r.at(-1))===s}))}const C=e=>{throw e instanceof DOMException&&e.name==="AbortError"||A.emit("error",{source:"checkout",type:"network",error:e}),e},U={cart:T,customer:q,estimateShippingMethods:b,storeConfig:v};function M(e,t){return t.split(".").reduce((s,r)=>s&&s[r]!==void 0?s[r]:void 0,e)}const E={cart:null,customer:null,estimateShippingMethods:null,storeConfig:null};async function N(e){const{defaultValueOnFail:t,options:s,path:r,query:a,queueName:u,signalType:o,transformer:h,type:S}=e,n=U[o],g=Symbol();E[o]=g,n.value={...n.value,pending:!0};try{const{data:p,errors:f}=await(S==="mutation"?k(()=>_(a,s).catch(C),u):_(a,{method:"GET",cache:"no-cache",...s}).catch(C));if(f){const m=I(f);if(m.length>0)throw new D(m)}let c=M(p,r);if(c===void 0)throw new Error(`No data found at path: ${r}`);return h&&(c=h(c)),n.value={...n.value,data:c},setTimeout(()=>{n.value={...n.value,pending:E[o]===g?!1:n.value.pending}},0),c}catch(p){if(t)return n.value={pending:!1,data:t},t;if(p.name==="AbortError")return;throw n.value={...n.value,pending:!1},p}}const F=`
|
|
4
|
-
query getStoreConfig {
|
|
5
|
-
storeConfig {
|
|
6
|
-
default_country
|
|
7
|
-
is_guest_checkout_enabled
|
|
8
|
-
is_one_page_checkout_enabled
|
|
9
|
-
shopping_cart_display_shipping
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
`,L="US",d={defaultCountry:L,isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1,shoppingCartDisplaySetting:{shipping:l.EXCLUDING_TAX}},ee=async()=>await N({type:"query",query:F,options:{method:"GET",cache:"no-cache"},path:"storeConfig",signalType:"storeConfig",transformer:P,defaultValueOnFail:d});function O(e){switch(e){case 1:return l.EXCLUDING_TAX;case 2:return l.INCLUDING_TAX;case 3:return l.INCLUDING_EXCLUDING_TAX;default:return l.EXCLUDING_TAX}}function P(e){if(!e)return d;const{default_country:t,is_guest_checkout_enabled:s,is_one_page_checkout_enabled:r,shopping_cart_display_shipping:a}=e;return{defaultCountry:t||d.defaultCountry,isGuestCheckoutEnabled:s||d.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:r||d.isOnePageCheckoutEnabled,shoppingCartDisplaySetting:{shipping:O(a)}}}const{setEndpoint:te,setFetchGraphQlHeader:se,removeFetchGraphQlHeader:re,setFetchGraphQlHeaders:ne,fetchGraphQl:_,getConfig:ae}=new G().getMethods();export{L as D,D as F,i as I,z as M,d as S,B as U,W as a,J as b,Y as c,N as d,$ as e,K as f,te as g,se as h,ne as i,_ as j,ae as k,ee as l,C as m,Z as n,re as r,j as s};
|