@dropins/storefront-checkout 0.1.0-alpha58 → 0.1.0-alpha60

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,18 +1,4 @@
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 setPaymentMethod: (paymentMethod: string) => Promise<import('../../data/models/cart').Cart | null | undefined>;
1
+ import { SetPaymentMethodOnCartInput } from '../../__generated__/types';
2
+
3
+ export declare const setPaymentMethod: (paymentMethod: SetPaymentMethodOnCartInput['payment_method']) => Promise<import('../../data/models/cart').Cart | null | undefined>;
18
4
  //# sourceMappingURL=setPaymentMethod.d.ts.map
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2024 Adobe
2
2
  All Rights Reserved. */
3
- import{c as S,b as T,e as A,a as b,T as i}from"./store-config.js";import"./ServerErrorSignal.js";import{events as v}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},V=new Proxy(x,{set(e,t,s){return e[t]=s,!0},get(e,t){return e[t]}});class w extends Error{constructor(t){super(t.map(s=>s.message).join(" ")),this.name="FetchError"}}class a extends Error{constructor(t){super(t),this.name="InvalidArgument"}}class j extends Error{constructor(t){super(t),this.name="UnexpectedError"}}class B extends a{constructor(){super("Cart ID is required")}}class z extends a{constructor(){super("Email is required")}}class Y extends a{constructor(){super("Payment method code is required")}}class $ extends a{constructor(){super("Shipping address is required")}}class J extends a{constructor(){super("Billing address is required")}}class K extends a{constructor(){super("Country Code is required")}}const p=[];function D(e){return new Promise((t,s)=>{p.push(e);const r=()=>{p[0]===e?e().then(t).catch(s).finally(()=>p.shift()):setTimeout(r,100)};r()})}const k=["sender_email","recipient_email"];function I(e){return e.filter(t=>!t.path||!k.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"||v.emit("error",{source:"checkout",type:"network",error:e}),e},M={cart:S,customer:T,estimateShippingMethods:A,storeConfig:b};function U(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 q(e){const{defaultValueOnFail:t,query:s,options:r,path:c,signalType:d,type:y,transformer:h}=e,n=M[d],g=Symbol();E[d]=g,n.value={...n.value,pending:!0};try{const{data:l,errors:f}=await(y==="mutation"?D(()=>_(s,r).catch(C)):_(s,{method:"GET",cache:"no-cache",...r}).catch(C));if(f){const m=I(f);if(m.length>0)throw new w(m)}let o=U(l,c);if(o===void 0)throw new Error(`No data found at path: ${c}`);return h&&(o=h(o)),n.value={...n.value,data:o},setTimeout(()=>{n.value={...n.value,pending:E[d]===g?!1:n.value.pending}},0),o}catch(l){if(t)return n.value={pending:!1,data:t},t;if(l.name==="AbortError")return;throw n.value={...n.value,pending:!1},l}}const N=`
3
+ import{c as S,d as T,e as A,a as v,T as i}from"./store-config.js";import"./ServerErrorSignal.js";import{events as G}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import{FetchGraphQL as b}from"@dropins/tools/fetch-graphql.js";const x={authenticated:!1,cartId:null,initialized:!1},V=new Proxy(x,{set(e,t,s){return e[t]=s,!0},get(e,t){return e[t]}});class w extends Error{constructor(t){super(t.map(s=>s.message).join(" ")),this.name="FetchError"}}class a extends Error{constructor(t){super(t),this.name="InvalidArgument"}}class j extends Error{constructor(t){super(t),this.name="UnexpectedError"}}class B extends a{constructor(){super("Cart ID is required")}}class z extends a{constructor(){super("Email is required")}}class Y extends a{constructor(){super("Payment method code is required")}}class $ extends a{constructor(){super("Shipping address is required")}}class J extends a{constructor(){super("Billing address is required")}}class K extends a{constructor(){super("Country Code is required")}}const p=[];function D(e){return new Promise((t,s)=>{p.push(e);const r=()=>{p[0]===e?e().then(t).catch(s).finally(()=>p.shift()):setTimeout(r,100)};r()})}const k=["sender_email","recipient_email"];function I(e){return e.filter(t=>!t.path||!k.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"||G.emit("error",{source:"checkout",type:"network",error:e}),e},M={cart:S,customer:T,estimateShippingMethods:A,storeConfig:v};function U(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 q(e){const{defaultValueOnFail:t,query:s,options:r,path:c,signalType:d,type:y,transformer:h}=e,n=M[d],g=Symbol();E[d]=g,n.value={...n.value,pending:!0};try{const{data:l,errors:f}=await(y==="mutation"?D(()=>_(s,r).catch(C)):_(s,{method:"GET",cache:"no-cache",...r}).catch(C));if(f){const m=I(f);if(m.length>0)throw new w(m)}let o=U(l,c);if(o===void 0)throw new Error(`No data found at path: ${c}`);return h&&(o=h(o)),n.value={...n.value,data:o},setTimeout(()=>{n.value={...n.value,pending:E[d]===g?!1:n.value.pending}},0),o}catch(l){if(t)return n.value={pending:!1,data:t},t;if(l.name==="AbortError")return;throw n.value={...n.value,pending:!1},l}}const N=`
4
4
  query getStoreConfig {
5
5
  storeConfig {
6
6
  default_country
@@ -9,4 +9,4 @@ import{c as S,b as T,e as A,a as b,T as i}from"./store-config.js";import"./Serve
9
9
  shopping_cart_display_shipping
10
10
  }
11
11
  }
12
- `,F="US",u={defaultCountry:F,isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1,shoppingCartDisplaySetting:{shipping:i.EXCLUDING_TAX}},W=async()=>await q({type:"query",query:N,options:{method:"GET",cache:"no-cache"},path:"storeConfig",signalType:"storeConfig",transformer:O,defaultValueOnFail:u});function L(e){switch(e){case 1:return i.EXCLUDING_TAX;case 2:return i.INCLUDING_TAX;case 3:return i.INCLUDING_EXCLUDING_TAX;default:return i.EXCLUDING_TAX}}function O(e){if(!e)return u;const{default_country:t,is_guest_checkout_enabled:s,is_one_page_checkout_enabled:r,shopping_cart_display_shipping:c}=e;return{defaultCountry:t||u.defaultCountry,isGuestCheckoutEnabled:s||u.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:r||u.isOnePageCheckoutEnabled,shoppingCartDisplaySetting:{shipping:L(c)}}}const{setEndpoint:Z,setFetchGraphQlHeader:ee,removeFetchGraphQlHeader:te,setFetchGraphQlHeaders:se,fetchGraphQl:_,getConfig:re}=new G().getMethods();export{F as D,w as F,a as I,B as M,u as S,j as U,K as a,$ as b,z as c,q as d,Y as e,J as f,Z as g,ee as h,se as i,_ as j,re as k,W as l,C as m,te as r,V as s};
12
+ `,F="US",u={defaultCountry:F,isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1,shoppingCartDisplaySetting:{shipping:i.EXCLUDING_TAX}},W=async()=>await q({type:"query",query:N,options:{method:"GET",cache:"no-cache"},path:"storeConfig",signalType:"storeConfig",transformer:O,defaultValueOnFail:u});function L(e){switch(e){case 1:return i.EXCLUDING_TAX;case 2:return i.INCLUDING_TAX;case 3:return i.INCLUDING_EXCLUDING_TAX;default:return i.EXCLUDING_TAX}}function O(e){if(!e)return u;const{default_country:t,is_guest_checkout_enabled:s,is_one_page_checkout_enabled:r,shopping_cart_display_shipping:c}=e;return{defaultCountry:t||u.defaultCountry,isGuestCheckoutEnabled:s||u.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:r||u.isOnePageCheckoutEnabled,shoppingCartDisplaySetting:{shipping:L(c)}}}const{setEndpoint:Z,setFetchGraphQlHeader:ee,removeFetchGraphQlHeader:te,setFetchGraphQlHeaders:se,fetchGraphQl:_,getConfig:re}=new b().getMethods();export{F as D,w as F,a as I,B as M,u as S,j as U,K as a,$ as b,z as c,q as d,Y as e,J as f,Z as g,ee as h,se as i,_ as j,re as k,W as l,C as m,te as r,V as s};
@@ -1,9 +1,12 @@
1
1
  /*! Copyright 2024 Adobe
2
2
  All Rights Reserved. */
3
- import{s as r,M as o,e as n,d as s}from"./fetch-graphql.js";import{CHECKOUT_DATA_FRAGMENT as i}from"../fragments.js";import{b as m}from"./synchronizeCheckout.js";import"./store-config.js";import"./ServerErrorSignal.js";import{events as d}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const p=`
4
- mutation setPaymentMethod($cartId: String!, $paymentMethod: String!) {
3
+ import{s as o,M as r,e as n,d as s}from"./fetch-graphql.js";import{CHECKOUT_DATA_FRAGMENT as i}from"../fragments.js";import{b as m}from"./synchronizeCheckout.js";import"./store-config.js";import"./ServerErrorSignal.js";import{events as d}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const p=`
4
+ mutation setPaymentMethod(
5
+ $cartId: String!
6
+ $paymentMethod: PaymentMethodInput!
7
+ ) {
5
8
  setPaymentMethodOnCart(
6
- input: { cart_id: $cartId, payment_method: { code: $paymentMethod } }
9
+ input: { cart_id: $cartId, payment_method: $paymentMethod }
7
10
  ) {
8
11
  cart {
9
12
  ...CHECKOUT_DATA_FRAGMENT
@@ -12,4 +15,4 @@ import{s as r,M as o,e as n,d as s}from"./fetch-graphql.js";import{CHECKOUT_DATA
12
15
  }
13
16
 
14
17
  ${i}
15
- `,A=async t=>{const a=r.cartId;if(!a)throw new o;if(!t)throw new n;const e=await s({type:"mutation",query:p,options:{variables:{cartId:a,paymentMethod:t}},path:"setPaymentMethodOnCart.cart",signalType:"cart",transformer:m});return d.emit("checkout/updated",e||null),e};export{A as s};
18
+ `,A=async t=>{const a=o.cartId;if(!a)throw new r;if(!t)throw new n;const e=await s({type:"mutation",query:p,options:{variables:{cartId:a,paymentMethod:t}},path:"setPaymentMethodOnCart.cart",signalType:"cart",transformer:m});return d.emit("checkout/updated",e||null),e};export{A as s};
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2024 Adobe
2
2
  All Rights Reserved. */
3
- import{signal as i,effect as e}from"@dropins/tools/signals.js";const n=i(!0),s=i({pending:!1,data:void 0});e(()=>{var a;(a=s.value.data)!=null&&a.isVirtual&&(n.value=!1)});const d=i({pending:!1,data:void 0}),l=i({pending:!1,data:void 0}),g=i(void 0),N=i({data:void 0,pending:!1});var t=(a=>(a.EXCLUDING_TAX="EXCLUDING_TAX",a.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",a.INCLUDING_TAX="INCLUDING_TAX",a))(t||{});export{t as T,N as a,d as b,s as c,l as e,n as i,g as s};
3
+ import{signal as e,effect as i}from"@dropins/tools/signals.js";const n=e(!0),t=e({pending:!1,data:void 0});i(()=>{var a;(a=t.value.data)!=null&&a.isVirtual&&(n.value=!1)});const d=e({pending:!1,data:void 0}),l=e({pending:!1,data:void 0}),g=e(),c=e(void 0),N=e({data:void 0,pending:!1});var s=(a=>(a.EXCLUDING_TAX="EXCLUDING_TAX",a.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",a.INCLUDING_TAX="INCLUDING_TAX",a))(s||{});export{s as T,N as a,g as b,t as c,d,l as e,n as i,c as s};
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2024 Adobe
2
2
  All Rights Reserved. */
3
- import{s as i,M as C,d as l,l as A}from"./fetch-graphql.js";import{b,a as M,c}from"./store-config.js";import"./ServerErrorSignal.js";import{events as s}from"@dropins/tools/event-bus.js";import{merge as a,Initializer as T}from"@dropins/tools/lib.js";import{CHECKOUT_DATA_FRAGMENT as u,CUSTOMER_FRAGMENT as S}from"../fragments.js";const I=async(e=!1)=>{i.authenticated=e,e?await K():b.value={pending:!1,data:null}},x=e=>e==null,E=(e,t)=>e.amount.value-t.amount.value,m=e=>!(!e||!e.method_code||!e.method_title||x(e.amount.value)||!e.amount.currency),f=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(m(e))return f(e)},k=e=>{if(e)return e.filter(m).map(t=>f(t)).sort(E)},w=e=>e?!!e.code&&!!e.label:!1,z=e=>{if(!w(e))return;const{code:t,label:r,region_id:n}=e;return n?{code:t,name:r,id:n}:{code:t,name:r}},R=e=>{const{code:t,label:r}=e;return{value:t,label:r}},q=e=>e?"code"in e&&"value"in e:!1,G=e=>e.filter(q).map(t=>{const{code:r,value:n}=t;return{code:r,value:n}}),d=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 d(e)},P=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:r,selected_shipping_method:n,same_as_billing:o,...v}=t;return{...d(v),availableShippingMethods:k(r),selectedShippingMethod:N(n),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:r,title:n}=t;return{code:r,title:n}})},D=e=>{var r,n,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=(n=(r=_.getConfig().models)==null?void 0:r.CartModel)==null?void 0:n.transformer)==null?void 0:o.call(n,e))},F=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=_.getConfig().models)==null?void 0:r.CustomerModel)==null?void 0:n.transformer)==null?void 0:o.call(n,e))},U=`
3
+ import{s as i,M as C,d as l,l as A}from"./fetch-graphql.js";import{d as b,a as M,c}from"./store-config.js";import"./ServerErrorSignal.js";import{events as s}from"@dropins/tools/event-bus.js";import{merge as a,Initializer as T}from"@dropins/tools/lib.js";import{CHECKOUT_DATA_FRAGMENT as u,CUSTOMER_FRAGMENT as S}from"../fragments.js";const I=async(e=!1)=>{i.authenticated=e,e?await K():b.value={pending:!1,data:null}},x=e=>e==null,E=(e,t)=>e.amount.value-t.amount.value,m=e=>!(!e||!e.method_code||!e.method_title||x(e.amount.value)||!e.amount.currency),f=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(m(e))return f(e)},k=e=>{if(e)return e.filter(m).map(t=>f(t)).sort(E)},w=e=>e?!!e.code&&!!e.label:!1,z=e=>{if(!w(e))return;const{code:t,label:r,region_id:n}=e;return n?{code:t,name:r,id:n}:{code:t,name:r}},R=e=>{const{code:t,label:r}=e;return{value:t,label:r}},q=e=>e?"code"in e&&"value"in e:!1,G=e=>e.filter(q).map(t=>{const{code:r,value:n}=t;return{code:r,value:n}}),d=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 d(e)},P=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:r,selected_shipping_method:n,same_as_billing:o,...v}=t;return{...d(v),availableShippingMethods:k(r),selectedShippingMethod:N(n),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:r,title:n}=t;return{code:r,title:n}})},D=e=>{var r,n,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=(n=(r=_.getConfig().models)==null?void 0:r.CartModel)==null?void 0:n.transformer)==null?void 0:o.call(n,e))},F=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=_.getConfig().models)==null?void 0:r.CustomerModel)==null?void 0:n.transformer)==null?void 0:o.call(n,e))},U=`
4
4
  query getCart($cartId: String!) {
5
5
  cart(cart_id: $cartId) {
6
6
  ...CHECKOUT_DATA_FRAGMENT
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2024 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as r,jsxs as s,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{s as H}from"../chunks/fetch-graphql.js";import{c as R,b as V}from"../chunks/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}from"../chunks/isEmailAvailable.js";import{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/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.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 r(W,{size:"medium",error:i,hint:g,children:r(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:[r(_,{id:"Checkout.LoginForm.account"}),r("a",{"data-testid":"sign-in-link",className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t,children:r(_,{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?r(Y,{}):s("div",{className:"checkout-login-form","data-testid":"checkout-login-form",children:[s("div",{className:"checkout-login-form__heading",children:[r("h2",{className:"checkout-login-form__title",children:l.Title}),i?r(Z,{onClick:d=>{d.preventDefault(),F==null||F()}}):r(Q,{onClick:d=>{d.preventDefault(),a==null||a(g)}})]}),i?s("div",{className:"checkout-login-form__customer-details",children:[r("div",{className:"checkout-login-form__customer-name",children:`${i.firstName} ${i.lastName}`}),r("div",{className:"checkout-login-form__customer-email",children:i.email})]}):r("div",{className:"checkout-login-form__content",children:s("form",{...L,className:j(["dropin-login-form__form",t]),name:m,noValidate:!0,children:[r("button",{type:"submit",disabled:!0,style:"display: none","aria-hidden":"true"}),r(O,{value:g,error:h,hint:o,onChange:k,onBlur:f,onInvalid:E})]})})]})},Y=()=>s(U,{"data-testid":"login-form-skeleton",children:[r(x,{variant:"heading",fullWidth:!0}),r(x,{size:"medium",fullWidth:!0})]}),Z=({onClick:t})=>s("p",{className:"checkout-login-form__sign-out",children:[r(_,{id:"Checkout.LoginForm.switch"}),r("a",{className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t,children:r(_,{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),rr=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=e=>e.valid?"":e.valueMissing?c.LoginFormMissingEmailError:c.LoginFormInvalidEmailError,B=e=>N(e)?"":e===""?c.LoginFormMissingEmailError:c.LoginFormInvalidEmailError,M=e=>{const n=e.target;u(n.value),f(""),E(!0)},T=e=>{const n=e.target;f(B(n.value))},z=e=>{const n=e.target;f(A(n.validity))};C(()=>{!a||!l||(F(!1),u(l.email||""))},[l,a]),C(()=>{if(a||H.authenticated)return;const e=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)}))},rr);return()=>{e&&clearTimeout(e)}},[d,o,a]);const I=k?"":s(w,{children:[c.LoginFormEmailExistsAlreadyHaveAccount," ",r("a",{href:"#",onClick:e=>{e.preventDefault(),t==null||t(o)},children:c.LoginFormEmailExistsSignInButton})," ",c.LoginFormEmailExistsForFasterCheckout]}),$=e=>{t==null||t(N(e)?e:"")},P=p?{firstName:p.firstName,lastName:p.lastName,email:p.email}:void 0;return r(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 kr=J(y);export{kr as LoginForm,kr as default};
3
+ import{jsx as r,jsxs as s,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{s as H}from"../chunks/fetch-graphql.js";import{c as R,d as V}from"../chunks/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}from"../chunks/isEmailAvailable.js";import{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/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.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 r(W,{size:"medium",error:i,hint:g,children:r(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:[r(_,{id:"Checkout.LoginForm.account"}),r("a",{"data-testid":"sign-in-link",className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t,children:r(_,{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?r(Y,{}):s("div",{className:"checkout-login-form","data-testid":"checkout-login-form",children:[s("div",{className:"checkout-login-form__heading",children:[r("h2",{className:"checkout-login-form__title",children:l.Title}),i?r(Z,{onClick:d=>{d.preventDefault(),F==null||F()}}):r(Q,{onClick:d=>{d.preventDefault(),a==null||a(g)}})]}),i?s("div",{className:"checkout-login-form__customer-details",children:[r("div",{className:"checkout-login-form__customer-name",children:`${i.firstName} ${i.lastName}`}),r("div",{className:"checkout-login-form__customer-email",children:i.email})]}):r("div",{className:"checkout-login-form__content",children:s("form",{...L,className:j(["dropin-login-form__form",t]),name:m,noValidate:!0,children:[r("button",{type:"submit",disabled:!0,style:"display: none","aria-hidden":"true"}),r(O,{value:g,error:h,hint:o,onChange:k,onBlur:f,onInvalid:E})]})})]})},Y=()=>s(U,{"data-testid":"login-form-skeleton",children:[r(x,{variant:"heading",fullWidth:!0}),r(x,{size:"medium",fullWidth:!0})]}),Z=({onClick:t})=>s("p",{className:"checkout-login-form__sign-out",children:[r(_,{id:"Checkout.LoginForm.switch"}),r("a",{className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t,children:r(_,{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),rr=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=e=>e.valid?"":e.valueMissing?c.LoginFormMissingEmailError:c.LoginFormInvalidEmailError,B=e=>N(e)?"":e===""?c.LoginFormMissingEmailError:c.LoginFormInvalidEmailError,M=e=>{const n=e.target;u(n.value),f(""),E(!0)},T=e=>{const n=e.target;f(B(n.value))},z=e=>{const n=e.target;f(A(n.validity))};C(()=>{!a||!l||(F(!1),u(l.email||""))},[l,a]),C(()=>{if(a||H.authenticated)return;const e=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)}))},rr);return()=>{e&&clearTimeout(e)}},[d,o,a]);const I=k?"":s(w,{children:[c.LoginFormEmailExistsAlreadyHaveAccount," ",r("a",{href:"#",onClick:e=>{e.preventDefault(),t==null||t(o)},children:c.LoginFormEmailExistsSignInButton})," ",c.LoginFormEmailExistsForFasterCheckout]}),$=e=>{t==null||t(N(e)?e:"")},P=p?{firstName:p.firstName,lastName:p.lastName,email:p.email}:void 0;return r(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 kr=J(y);export{kr as LoginForm,kr as default};
@@ -12,6 +12,9 @@ export interface PaymentMethodHandlerSlotContext {
12
12
  replaceHTML: (domElement: HTMLElement) => void;
13
13
  }
14
14
  export interface PaymentMethodsProps extends HTMLAttributes<HTMLDivElement> {
15
+ setOnChange?: {
16
+ [key: string]: boolean;
17
+ } | undefined;
15
18
  slots?: {
16
19
  Main?: SlotProps<PaymentMethodsMainSlotContext>;
17
20
  Handlers?: PaymentMethodHandlerSlots;
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2024 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as n,jsxs as M,Fragment as R}from"@dropins/tools/preact-jsx-runtime.js";import{s as D}from"../chunks/fetch-graphql.js";import{c as C}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{classes as H,Slot as L}from"@dropins/tools/lib.js";import{s as $}from"../chunks/setPaymentMethod.js";/* empty css */import{IllustratedMessage as B,Icon as U,ProgressSpinner as Z,ToggleButton as F,Skeleton as q,SkeletonRow as y}from"@dropins/tools/components.js";import*as g from"@dropins/tools/preact-compat.js";import{useState as S,useCallback as T,useEffect as w}from"@dropins/tools/preact-compat.js";import{useText as G}from"@dropins/tools/i18n.js";import{w as J}from"../chunks/withConditionalRendering.js";import{useRef as K}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const Q=e=>g.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},g.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"}),g.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),g.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),X=({code:e,loading:a,selected:r,onChange:d,title:h})=>n(F,{className:"checkout-payment-methods__method",label:h,name:"payment-method",value:e,selected:r,onChange:d,busy:a}),Y=({className:e,paymentMethodContent:a,loading:r=!1,initializing:d=!1,onChange:h=()=>{},options:c,selection:k})=>{const o=G({Title:"Checkout.PaymentMethods.title",EmptyState:"Checkout.PaymentMethods.emptyState"});return d?n(ee,{}):M("div",{className:H(["checkout-payment-methods",e]),children:[n("h2",{className:"checkout-payment-methods__title",children:o.Title}),!r&&c.length===0&&n(B,{icon:n(U,{source:Q}),message:n("p",{children:o.EmptyState})}),M("div",{className:H(["checkout-payment-methods__wrapper"]),children:[r&&n(Z,{className:"checkout-payment-methods__spinner"}),n("div",{className:H(["checkout-payment-methods__methods",["checkout-payment-methods--loading",r],["checkout-payment-methods--full-width",c.length%2!==0]]),children:c==null?void 0:c.map(i=>n(X,{code:i.code,onChange:h,selected:i.code===k,title:i.title},i.code))}),a&&n("div",{className:"checkout-payment-methods__content",children:a})]})]})},ee=()=>M(q,{"data-testid":"payment-methods-skeleton",children:[n(y,{variant:"heading",size:"medium"}),n(y,{variant:"empty",size:"medium"}),n(y,{size:"xlarge",fullWidth:!0}),n(y,{size:"xlarge",fullWidth:!0})]}),N={free:e=>{const a=document.createElement("div");a.innerText="",e.replaceHTML(a)},checkmo:e=>{const a=document.createElement("div");a.innerText="",e.replaceHTML(a)}},te=(e,a)=>{const r=K(e);return a(r.current,e)||(r.current=e),r.current},V=({slots:e})=>{var x,_;const[a,r]=S(),[d,h]=S(N),[c,k]=S(!0),o=C.value.data,i=!!C.value.data,W=C.value.pending,j=(o==null?void 0:o.isVirtual)??!1,z=(x=o==null?void 0:o.shippingAddresses)==null?void 0:x[0],A=(o==null?void 0:o.availablePaymentMethods)||[],l=(_=o==null?void 0:o.selectedPaymentMethod)==null?void 0:_.code,E=j?!0:!!z,m=te(A,(t,s)=>t.length!==s.length?!1:t.every((p,v)=>p.code===s[v].code)),u=T(t=>{r(t),!(!t||!E)&&t!==l&&$(t).catch(console.error)},[E,l]);w(()=>{if(!i)return;if(!!!(m!=null&&m.length)){u(void 0);return}const s=m[0].code;if(!l){u(s);return}const p=m.some(v=>v.code===l);u(p?l:s)},[m,i,l,u]);const I=t=>{u(t)},b=T((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}))},[]);w(()=>{e!=null&&e.Handlers&&Object.entries(e.Handlers).forEach(([t,s])=>{b(t,s)})},[b,e==null?void 0:e.Handlers]);const f=e!=null&&e.Main?n(L,{name:"PaymentMethods",slot:e==null?void 0:e.Main,context:{replaceHTML(t){this.replaceWith(t),k(!1)}}}):null,P=a?d[a]:null,O=P?n(L,{name:"PaymentMethodContent",slot:P,context:{cartId:D.cartId||"",replaceHTML(t){this.replaceWith(t)}}},P):void 0;return w(()=>{!c&&d!=N&&console.warn("Payment method handlers you have added are ignored because the default content has been replaced")},[c,d]),M(R,{children:[f&&n(f.type,{ref:f.ref,...f.props}),c&&n(Y,{initializing:i===!1,loading:i&&W,onChange:I,options:m,paymentMethodContent:O,selection:a})]})};V.displayName="PaymentMethodsContainer";const ke=J(V);export{ke as PaymentMethods,ke as default};
3
+ import{jsx as n,jsxs as v,Fragment as D}from"@dropins/tools/preact-jsx-runtime.js";import{s as $}from"../chunks/fetch-graphql.js";import{c as H,b as y}from"../chunks/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 b}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/fetch-graphql.js";import"@dropins/tools/signals.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,E=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||!E)&&t!==m&&o[t]!==!1&&B({code:t}).catch(console.error)},[E,m,o]);b(()=>{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}))},[]);b(()=>{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 b(()=>{!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 Me=K(W);export{Me as PaymentMethods,Me as default};
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2024 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as c}from"@dropins/tools/preact-jsx-runtime.js";import{U as E}from"../chunks/fetch-graphql.js";import{c as P}from"../chunks/store-config.js";import{s as g}from"../chunks/ServerErrorSignal.js";import{events as v}from"@dropins/tools/event-bus.js";import{classes as S}from"@dropins/tools/lib.js";import{p as b}from"../chunks/placeOrder2.js";/* empty css */import{Button as U}from"@dropins/tools/components.js";import{Text as w,useText as N}from"@dropins/tools/i18n.js";import{w as T}from"../chunks/withConditionalRendering.js";import{useState as z,useCallback as p,useEffect as H}from"@dropins/tools/preact-compat.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const I=r=>r instanceof TypeError||r instanceof E,M=({className:r,disabled:t=!1,onClick:o})=>c("div",{className:S(["checkout-place-order",r]),children:c(U,{className:"checkout-place-order__button","data-testid":"place-order-button",disabled:t,onClick:o,size:"medium",type:"submit",variant:"primary",children:c(w,{id:"Checkout.PlaceOrder.button"})},"placeOrder")}),u=({disabled:r=!1,handleValidation:t,onPlaceOrder:o,...f})=>{var l;const[h,O]=z(!1),{data:s,pending:k}=P.value,C=!!s,n=((l=s==null?void 0:s.selectedPaymentMethod)==null?void 0:l.code)||"",i=N({CheckoutUnexpectedError:"Checkout.ServerError.unexpected"}),m=p(e=>{g.value=I(e)?i.CheckoutUnexpectedError:e.message},[i]),x=p(async()=>{try{if(!(t?t():!0))return;o?await o({code:n}):await b()}catch(e){m(e)}},[t,o,n,m]);return H(()=>{const e=v.on("cart/initialized",a=>{const y=(a==null?void 0:a.items)||[];O(y.some(d=>d.outOfStock||d.insufficientQuantity))},{eager:!0});return()=>{e==null||e.off()}},[]),c(M,{...f,onClick:x,disabled:r||!C||k||h})};u.displayName="PlaceOrderContainer";const Y=T(u);export{Y as PlaceOrder,Y as default};
3
+ import{jsx as a}from"@dropins/tools/preact-jsx-runtime.js";import{U as x}from"../chunks/fetch-graphql.js";import{c as E,b as g}from"../chunks/store-config.js";import{s as v}from"../chunks/ServerErrorSignal.js";import{events as y}from"@dropins/tools/event-bus.js";import{classes as S}from"@dropins/tools/lib.js";import{p as b}from"../chunks/placeOrder2.js";/* empty css */import{Button as P}from"@dropins/tools/components.js";import{Text as U,useText as w}from"@dropins/tools/i18n.js";import{w as N}from"../chunks/withConditionalRendering.js";import{useState as T,useCallback as m,useEffect as z}from"@dropins/tools/preact-compat.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const D=r=>r instanceof TypeError||r instanceof x,H=({className:r,disabled:t=!1,onClick:o})=>a("div",{className:S(["checkout-place-order",r]),children:a(P,{className:"checkout-place-order__button","data-testid":"place-order-button",disabled:t,onClick:o,size:"medium",type:"submit",variant:"primary",children:a(U,{id:"Checkout.PlaceOrder.button"})},"placeOrder")}),l=({disabled:r=!1,handleValidation:t,onPlaceOrder:o,...p})=>{const[u,d]=T(!1),{data:f,pending:O}=E.value,h=!!f,c=w({CheckoutUnexpectedError:"Checkout.ServerError.unexpected"}),n=m(e=>{v.value=D(e)?c.CheckoutUnexpectedError:e.message},[c]),k=m(async()=>{try{if(!(t?t():!0))return;o?await o({code:g.value||""}):await b()}catch(e){n(e)}},[t,o,n]);return z(()=>{const e=y.on("cart/initialized",s=>{const C=(s==null?void 0:s.items)||[];d(C.some(i=>i.outOfStock||i.insufficientQuantity))},{eager:!0});return()=>{e==null||e.off()}},[]),a(H,{...p,onClick:k,disabled:r||!h||O||u})};l.displayName="PlaceOrderContainer";const X=N(l);export{X as PlaceOrder,X as default};
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2024 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as i,jsxs as L,Fragment as R}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/fetch-graphql.js";import{s as v,e as M,c as x,a as V}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import{events as T}from"@dropins/tools/event-bus.js";import{classes as W,Slot as O}from"@dropins/tools/lib.js";import{s as P}from"../chunks/setShippingMethods.js";/* empty css */import{IllustratedMessage as Z,Icon as $,ProgressSpinner as q,RadioButton as F,Price as G,Skeleton as J,SkeletonRow as S}from"@dropins/tools/components.js";import*as p from"@dropins/tools/preact-compat.js";import{useRef as K,useEffect as z,useCallback as Q,useMemo as X}from"@dropins/tools/preact-compat.js";import{useText as Y}from"@dropins/tools/i18n.js";import{useState as I,useEffect as _}from"@dropins/tools/preact-hooks.js";import{w as D}from"../chunks/withConditionalRendering.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../chunks/synchronizeCheckout.js";import"../fragments.js";const U=e=>({countryCode:e.country_id,postCode:e.postcode||"",...e.region_id?{regionId:Number(e.region_id)}:{...e.region?{region:e.region}:{}}}),ee=e=>({carrierCode:e.carrier.code||"",methodCode:e.code||"",amount:e.amount,amountExclTax:e.amountExclTax,amountInclTax:e.amountInclTax}),te=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"})),ne=({className:e,isLoading:t=!1,onSelectionChange:n=()=>{},options:r,selection:a,...s})=>{const c=Y({Title:"Checkout.ShippingMethods.title",EmptyState:"Checkout.ShippingMethods.emptyState"});return r===void 0?i(oe,{}):L("div",{...s,className:W(["checkout-shipping-methods",e]),children:[i("h3",{className:"checkout-shipping-methods__title",children:c.Title}),!t&&r.length===0&&i(Z,{icon:i($,{source:te}),message:i("p",{children:c.EmptyState})}),L("div",{className:W(["checkout-shipping-methods__content"]),children:[t&&i(q,{className:"checkout-shipping-methods__spinner"}),i("div",{className:W(["checkout-shipping-methods__options",["checkout-shipping-methods__options--loading",t]]),children:r.map(o=>i(F,{"data-testid":"shipping-method-radiobutton","aria-busy":t,id:o.value,name:"shipping-method",className:"checkout-shipping-methods__method",label:L(R,{children:[i(G,{amount:o.amount.value,currency:o.amount.currency})," ",i("span",{children:o.carrier.title})]}),description:o.title,value:o.value,checked:(a==null?void 0:a.value)===o.value,onChange:()=>n(o)},o.value))})]})]})},oe=()=>L(J,{"data-testid":"shipping-methods-skeleton",children:[i(S,{variant:"heading",size:"small"}),i(S,{variant:"empty",size:"small"}),i(S,{size:"medium",fullWidth:!0}),i(S,{size:"medium",fullWidth:!0})]});function ie(){var C;const[e,t]=I(),[n,r]=I();_(()=>{T.on("checkout/estimate-shipping-address",({address:j,isValid:g})=>{t({address:j,isValid:g})})},[]),_(()=>{r(v.value)},[v.value]),_(()=>{M.value.pending?r(void 0):r(v.value)},[M.value.pending]);const{country_id:a,region_id:s,region:c,postcode:o}=(e==null?void 0:e.address)||{},f=!!e,l=x.value.data,k=!!((C=l==null?void 0:l.shippingAddresses)!=null&&C[0]),u=e==null?void 0:e.isValid;_(()=>{k||u||!n||!f||T.emit("shipping/estimate",{address:U({country_id:a,region_id:s,region:c,postcode:o}),shippingMethod:ee(n)})},[n,a,s,c,o,f,k,u])}const b=(e,t)=>e.code===t.code&&e.carrier.code===t.carrier.code,re=e=>{var r,a,s,c;const t=(c=(s=(a=(r=x.value.data)==null?void 0:r.shippingAddresses)==null?void 0:a[0])==null?void 0:s.selectedShippingMethod)==null?void 0:c.carrier.code,n=K();z(()=>{t!==n.current&&(n.current=t,t&&(e==null||e()))},[t,e])};function se({onCheckoutDataUpdate:e,preSelectedMethod:t,onShippingMethodSelect:n}){const a=!V.value.data,s=x.value.data,c=x.value.pending,o=M.value.data,f=M.value.pending,l=v.value,k=s==null?void 0:s.shippingAddresses,u=k==null?void 0:k[0],C=!!u,j=u==null?void 0:u.availableShippingMethods,g=u==null?void 0:u.selectedShippingMethod,d=j||o,w=Q(m=>{if(!C)return;const E={method_code:m.code,carrier_code:m.carrier.code};P([E]).catch(y=>{console.error("Setting shipping methods on cart failed:",y)})},[C,e]),B=m=>{v.value=m,n==null||n(m)},h=X(()=>{if(!(d!=null&&d.length))return;const m=d[0],E=l||g;return E?d.some(H=>b(H,E))?E:m:d.find(N=>N.carrier.code===(t==null?void 0:t.carrierCode)&&N.code===(t==null?void 0:t.methodCode))||m},[l,g,d,t]);return z(()=>{h&&((!l||!b(h,l))&&(v.value=h,n==null||n(h)),(!g||!b(h,g))&&w(h))},[h,l,g,w,n]),{isLoading:c||a||f,options:d,selection:h,onSelectionChange:B}}const A=({preSelectedMethod:e,onCheckoutDataUpdate:t,shippingMethodsSlot:n,onShippingMethodSelect:r,initialData:a,...s})=>{const{isLoading:c,options:o,selection:f,onSelectionChange:l}=se({preSelectedMethod:e,onCheckoutDataUpdate:t,onShippingMethodSelect:r});return ie(),re(t),L(R,{children:[i(ne,{...s,isLoading:c,onSelectionChange:l,options:o,selection:f}),!c&&n&&i(O,{name:"ShippingMethods",slot:n})]})};A.displayName="ShippingMethodsContainer";const Me=D(A);export{Me as ShippingMethods,Me as default};
3
+ import{jsx as o,jsxs as E,Fragment as I}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/fetch-graphql.js";import{s as k,e as M,c as x,a as B}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import{events as N}from"@dropins/tools/event-bus.js";import{classes as j,Slot as V}from"@dropins/tools/lib.js";import{s as O}from"../chunks/setShippingMethods.js";/* empty css */import{IllustratedMessage as P,Icon as Z,ProgressSpinner as $,RadioButton as q,Price as F,Skeleton as G,SkeletonRow as S}from"@dropins/tools/components.js";import*as d from"@dropins/tools/preact-compat.js";import{useRef as J,useEffect as R,useCallback as K,useMemo as Q}from"@dropins/tools/preact-compat.js";import{useText as X}from"@dropins/tools/i18n.js";import{useState as T,useEffect as _}from"@dropins/tools/preact-hooks.js";import{w as Y}from"../chunks/withConditionalRendering.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../chunks/synchronizeCheckout.js";import"../fragments.js";const D=e=>({countryCode:e.country_id,postCode:e.postcode||"",...e.region_id?{regionId:Number(e.region_id)}:{...e.region?{region:e.region}:{}}}),U=e=>({carrierCode:e.carrier.code||"",methodCode:e.code||"",amount:e.amount,amountExclTax:e.amountExclTax,amountInclTax:e.amountInclTax}),ee=e=>d.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},d.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"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.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"}),d.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"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),te=({className:e,isLoading:t=!1,onSelectionChange:c=()=>{},options:i,selection:r,...a})=>{const s=X({Title:"Checkout.ShippingMethods.title",EmptyState:"Checkout.ShippingMethods.emptyState"});return i===void 0?o(ne,{}):E("div",{...a,className:j(["checkout-shipping-methods",e]),children:[o("h3",{className:"checkout-shipping-methods__title",children:s.Title}),!t&&i.length===0&&o(P,{icon:o(Z,{source:ee}),message:o("p",{children:s.EmptyState})}),E("div",{className:j(["checkout-shipping-methods__content"]),children:[t&&o($,{className:"checkout-shipping-methods__spinner"}),o("div",{className:j(["checkout-shipping-methods__options",["checkout-shipping-methods__options--loading",t]]),children:i.map(n=>o(q,{"data-testid":"shipping-method-radiobutton","aria-busy":t,id:n.value,name:"shipping-method",className:"checkout-shipping-methods__method",label:E(I,{children:[o(F,{amount:n.amount.value,currency:n.amount.currency})," ",o("span",{children:n.carrier.title})]}),description:n.title,value:n.value,checked:(r==null?void 0:r.value)===n.value,onChange:()=>c(n)},n.value))})]})]})},ne=()=>E(G,{"data-testid":"shipping-methods-skeleton",children:[o(S,{variant:"heading",size:"small"}),o(S,{variant:"empty",size:"small"}),o(S,{size:"medium",fullWidth:!0}),o(S,{size:"medium",fullWidth:!0})]});function oe(){var L;const[e,t]=T(),[c,i]=T();_(()=>{N.on("checkout/estimate-shipping-address",({address:f,isValid:p})=>{t({address:f,isValid:p})})},[]),_(()=>{i(k.value)},[k.value]),_(()=>{M.value.pending?i(void 0):i(k.value)},[M.value.pending]);const{country_id:r,region_id:a,region:s,postcode:n}=(e==null?void 0:e.address)||{},l=!!e,h=x.value.data,u=!!((L=h==null?void 0:h.shippingAddresses)!=null&&L[0]),v=e==null?void 0:e.isValid;_(()=>{u||v||!c||!l||N.emit("shipping/estimate",{address:D({country_id:r,region_id:a,region:s,postcode:n}),shippingMethod:U(c)})},[c,r,a,s,n,l,u,v])}const W=(e,t)=>e.code===t.code&&e.carrier.code===t.carrier.code,ie=e=>{var i,r,a,s;const t=(s=(a=(r=(i=x.value.data)==null?void 0:i.shippingAddresses)==null?void 0:r[0])==null?void 0:a.selectedShippingMethod)==null?void 0:s.carrier.code,c=J();R(()=>{t!==c.current&&(c.current=t,t&&(e==null||e()))},[t,e])};function re({preSelectedMethod:e,onShippingMethodSelect:t}){const i=!B.value.data,r=x.value.data,a=x.value.pending,s=M.value.data,n=M.value.pending,l=k.value,h=r==null?void 0:r.shippingAddresses,u=h==null?void 0:h[0],v=!!u,L=u==null?void 0:u.availableShippingMethods,f=u==null?void 0:u.selectedShippingMethod,p=L||s,b=K(g=>{if(!v)return;const C={method_code:g.code,carrier_code:g.carrier.code};O([C]).catch(w=>{console.error("Setting shipping methods on cart failed:",w)})},[v]),A=g=>{k.value=g,t==null||t(g)},m=Q(()=>{if(!(p!=null&&p.length))return;const g=p[0],C=l||f;return C?p.some(y=>W(y,C))?C:g:p.find(H=>H.carrier.code===(e==null?void 0:e.carrierCode)&&H.code===(e==null?void 0:e.methodCode))||g},[l,f,p,e]);return R(()=>{m&&((!l||!W(m,l))&&(k.value=m,t==null||t(m)),(!f||!W(m,f))&&b(m))},[m,l,f,b,t]),{isLoading:a||i||n,options:p,selection:m,onSelectionChange:A}}const z=({preSelectedMethod:e,onCheckoutDataUpdate:t,shippingMethodsSlot:c,onShippingMethodSelect:i,initialData:r,...a})=>{const{isLoading:s,options:n,selection:l,onSelectionChange:h}=re({preSelectedMethod:e,onCheckoutDataUpdate:t,onShippingMethodSelect:i});return oe(),ie(t),E(I,{children:[o(te,{...a,isLoading:s,onSelectionChange:h,options:n,selection:l}),!s&&c&&o(V,{name:"ShippingMethods",slot:c})]})};z.displayName="ShippingMethodsContainer";const _e=Y(z);export{_e as ShippingMethods,_e as default};
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-checkout", "version": "0.1.0-alpha58", "@dropins/tools": "~0.36.0"}
1
+ {"name": "@dropins/storefront-checkout", "version": "0.1.0-alpha60", "@dropins/tools": "~0.36.0"}
package/render.js CHANGED
@@ -4,6 +4,6 @@ All Rights Reserved. */
4
4
  .checkout-estimate-shipping{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-xxsmall);align-items:center;color:var(--color-neutral-800)}.checkout-estimate-shipping__label,.checkout-estimate-shipping__price{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.checkout-estimate-shipping__label--muted{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);color:var(--color-neutral-700)}.checkout-estimate-shipping__price--muted{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-estimate-shipping__price{text-align:right}.checkout-estimate-shipping__label--bold,.checkout-estimate-shipping__price--bold{font:var(--type-body-1-emphasized-font);letter-spacing:var(--type-body-1-emphasized-letter-spacing)}.checkout-estimate-shipping__caption{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);color:var(--color-neutral-700)}.cart-order-summary__shipping .dropin-skeleton{grid-template-columns:1fr}.checkout-login-form__heading{display:grid;grid-template-columns:1fr max-content;grid-auto-rows:max-content}.checkout-login-form__content{grid-auto-rows:max-content}.checkout-login-form__content .dropin-field__hint a{font-weight:400}.checkout-login-form__customer-details{display:grid;grid-auto-flow:row;gap:var(--spacing-xxsmall)}.checkout-login-form__customer-name{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.checkout-login-form__customer-email{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);color:var(--color-neutral-700)}.checkout-login-form__title{grid-column-start:1;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-login-form__sign-in,.checkout-login-form__sign-out{grid-column-start:2;color:var(--color-neutral-800);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);justify-self:flex-end;margin-top:var(--spacing-xxsmall)}a.checkout-login-form__link{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin-left:var(--spacing-xxsmall)}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-login-form__heading{grid-template-columns:repeat(1,1fr [col-start]);grid-template-rows:1fr}.checkout-login-form__sign-in,.checkout-login-form__sign-out{grid-column-start:1;align-self:flex-start;justify-self:flex-start;margin-top:0;margin-bottom:var(--spacing-medium)}}.order-confirmation-header{text-align:center;padding:var(--spacing-xxbig)}.order-confirmation-header__icon{margin-bottom:var(--spacing-small)}.order-confirmation-header__title{color:var(--color-neutral-800);font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);justify-content:center;margin:0}.order-confirmation-header__title:first-letter{text-transform:uppercase}.order-confirmation-header__order{color:var(--color-neutral-700);font:var(--type-details-overline-font);letter-spacing:var(--type-details-overline-letter-spacing);margin:var(--spacing-xxsmall) 0 0 0}.order-confirmation-header .success-icon{color:var(--color-positive-500)}.order-confirmation-create-account{display:grid;gap:var(--spacing-small);margin-top:var(--spacing-large)}.order-confirmation-create-account__message{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin:0}.order-confirmation-create-account__button{display:flex;margin:0 auto;text-align:center}.checkout-out-of-stock.dropin-card{border-color:var(--color-warning-500)}.checkout-out-of-stock .dropin-card__content{gap:var(--spacing-small);padding:var(--spacing-small)}.checkout-out-of-stock__title{color:var(--color-neutral-900);font:var(--type-body-2-strong-font);margin:0;display:flex;gap:var(--spacing-xxsmall);align-items:center;justify-content:left;text-align:center}.checkout-out-of-stock__message{color:var(--color-neutral-800);font:var(--type-body-2-default-font);margin:0}.checkout-out-of-stock__items{display:grid;grid-template-columns:repeat(5,100px);grid-gap:var(--spacing-small);list-style:none;padding:0;margin:0}.checkout-out-of-stock__item img{width:100%;height:auto}.checkout-out-of-stock__actions{display:flex;gap:var(--spacing-small);justify-content:flex-end}a.checkout-out-of-stock__action{font:var(--type-details-caption-1-font)}.checkout-out-of-stock__action{background:none;border:none;padding:0;cursor:pointer}.checkout-out-of-stock__action:hover{--textColor: var(--color-brand-700);text-decoration:solid underline var(--textColor);text-underline-offset:6px}.checkout-server-error{position:relative;text-align:center}.checkout-server-error__icon .error-icon{color:var(--color-alert-500)}.checkout-server-error a{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing)}
5
5
  .checkout-shipping-methods__title{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-shipping-methods__content{position:relative;display:block}.checkout-shipping-methods__method{margin-bottom:var(--spacing-medium);width:fit-content;cursor:pointer;font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-shipping-methods__method:last-child{margin-bottom:0}.dropin-radio-button__label .dropin-price{color:var(--color-neutral-800);font-weight:400}.checkout-shipping-methods__options--loading{opacity:.4;pointer-events:none}.checkout-shipping-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0}
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
- .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{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}}
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
9
  import{jsx as f}from"@dropins/tools/preact-jsx-runtime.js";import{Render as d}from"@dropins/tools/lib.js";import"./chunks/fetch-graphql.js";import"./chunks/store-config.js";import"./chunks/ServerErrorSignal.js";import{events as p}from"@dropins/tools/event-bus.js";import{c as y}from"./chunks/synchronizeCheckout.js";import{UIProvider as g}from"@dropins/tools/components.js";import{useState as b,useEffect as h}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"./fragments.js";function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var S=function(r){return E(r)&&!v(r)};function E(e){return!!e&&typeof e=="object"}function v(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||M(e)}var w=typeof Symbol=="function"&&Symbol.for,j=w?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 T(e,r){if(!r.customMerge)return a;var t=r.customMerge(e);return typeof t=="function"?t:a}function C(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(r){return Object.propertyIsEnumerable.call(e,r)}):[]}function l(e){return Object.keys(e).concat(C(e))}function m(e,r){try{return r in e}catch{return!1}}function I(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){I(e,n)||(m(e,n)&&t.isMergeableObject(r[n])?o[n]=T(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,k=D;const R=O(k),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"},OrderConfirmationHeader:{title:"{{name}}, thank you for your order!",defaultTitle:"Thank you for your order!",order:"ORDER #{{order}}",CreateAccount:{message:"Save your information for faster checkout next time.",button:"Create an account"}}},L={Checkout:B},_={default:L},U=({children:e})=>{var c;const[r,t]=b(),o=(c=y.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=R(_,o??{});return f(g,{lang:r,langDefinitions:n,children:e})},Q=new d(f(U,{}));export{U as Provider,Q as render};
@@ -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 selectedPaymentMethodSignal: import('@preact/signals-core').Signal<string | undefined>;
18
+ //# sourceMappingURL=SelectedPaymentMethodSignal.d.ts.map
@@ -18,6 +18,7 @@ export * from './CartSignal';
18
18
  export * from './CustomerSignal';
19
19
  export * from './EstimateShippingMethodsSignal';
20
20
  export * from './IsBillToShippingSignal';
21
+ export * from './SelectedPaymentMethodSignal';
21
22
  export * from './SelectedShippingMethodSignal';
22
23
  export * from './ServerErrorSignal';
23
24
  export * from './StoreConfigSignal';