@dropins/storefront-checkout 0.1.0-alpha38 → 0.1.0-alpha39
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/__generated__/types.d.ts +714 -1907
- package/api/estimateShippingMethods/fixtures.d.ts +1 -1
- package/api/getCart/graphql/getCart.graphql.d.ts +1 -1
- package/api/getCheckoutData/getCheckoutData.d.ts +2 -0
- package/api/getCheckoutData/index.d.ts +2 -0
- package/api/getCountries/getCountries.d.ts +1 -3
- package/api/getCustomer/fixtures.d.ts +5 -0
- package/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts +1 -1
- package/api/index.d.ts +4 -0
- package/api/initialize/listeners.d.ts +4 -0
- package/api/initializeCheckout/index.d.ts +2 -0
- package/api/initializeCheckout/initializeCheckout.d.ts +2 -0
- package/api/placeOrder/graphql/placeOrder.graphql.d.ts +1 -1
- package/api/resetCheckout/index.d.ts +2 -0
- package/api/resetCheckout/resetCheckout.d.ts +2 -0
- package/api/resetCustomer/index.d.ts +2 -0
- package/api/resetCustomer/resetCustomer.d.ts +2 -0
- package/api/utils/dispatchApiCall.d.ts +4 -0
- package/api.js +1 -1
- package/chunks/BillToShippingAddress2.js +1 -1
- package/chunks/BillingForm.js +1 -1
- package/chunks/LoginForm.js +1 -1
- package/chunks/PlaceOrder.js +1 -1
- package/chunks/ShippingForm.js +1 -1
- package/chunks/ShippingMethods.js +1 -1
- package/chunks/ToggleButton.js +1 -1
- package/chunks/ToggleButton2.js +1 -1
- package/chunks/address-form-fields.js +1 -43
- package/chunks/fixtures.js +16 -2
- package/chunks/getCart.graphql.js +12 -4
- package/chunks/getCustomer.js +34 -0
- package/chunks/getMultilineValues.js +43 -0
- package/chunks/placeOrder2.js +68 -35
- package/chunks/resetCustomer.js +7 -0
- package/chunks/setBillingAddress.js +3 -3
- package/chunks/setGuestEmailOnCart.js +1 -1
- package/chunks/setPaymentMethod.js +3 -3
- package/chunks/setShippingAddress.js +2 -2
- package/chunks/setShippingMethods.js +3 -3
- package/components/AddressForm/useAddressBackup.d.ts +2 -2
- package/components/EstimateShipping/EstimateShipping.d.ts +12 -0
- package/components/EstimateShipping/EstimateShippingSkeleton.d.ts +4 -0
- package/components/EstimateShipping/index.d.ts +4 -0
- package/components/LoginForm/LoginForm.d.ts +0 -1
- package/components/index.d.ts +1 -0
- package/containers/BillToShippingAddress.js +1 -1
- package/containers/BillingForm.js +1 -1
- package/containers/Checkout.js +1 -1
- package/containers/EstimateShipping/EstimateShipping.d.ts +4 -0
- package/containers/EstimateShipping/index.d.ts +3 -0
- package/containers/EstimateShipping.d.ts +3 -0
- package/containers/EstimateShipping.js +1 -0
- package/containers/LoginForm/LoginForm.d.ts +1 -1
- package/containers/LoginForm.js +1 -1
- package/containers/PaymentMethods.js +1 -1
- package/containers/PlaceOrder.js +1 -1
- package/containers/ShippingForm.js +1 -1
- package/containers/ShippingMethods.js +1 -1
- package/containers/index.d.ts +1 -0
- package/context/index.d.ts +0 -3
- package/data/models/address-form-fields.d.ts +2 -2
- package/data/models/order.d.ts +39 -4
- package/data/models/store-config.d.ts +8 -0
- package/data/transforms/transform-address.d.ts +10 -0
- package/data/transforms/transform-shipping-methods.d.ts +1 -1
- package/data/transforms/transform-store-config.d.ts +2 -1
- package/i18n/en_US.json.d.ts +8 -0
- package/lib/backup-data.d.ts +4 -0
- package/lib/index.d.ts +0 -1
- package/msw/fixtures/fragments/cart.d.ts +10 -0
- package/package.json +1 -1
- package/render.js +3 -3
- package/signals/CountryListSignal.d.ts +7 -0
- package/signals/index.d.ts +1 -1
- package/tests/integration/utils/setup.d.ts +1 -1
- package/chunks/address-form-fields2.js +0 -1
- package/chunks/getCountries.js +0 -7
- package/chunks/initialize.js +0 -14
- package/chunks/services.js +0 -1
- package/chunks/transform-shipping-methods.js +0 -1
- package/context/checkout.d.ts +0 -44
- package/context/countries.d.ts +0 -13
- package/context/services.d.ts +0 -13
- package/hooks/useAuthentication/index.d.ts +0 -2
- package/hooks/useAuthentication/useAuthentication.d.ts +0 -2
- package/lib/localStorage.d.ts +0 -10
- package/services/backup.d.ts +0 -17
- package/services/index.d.ts +0 -2
- package/signals/AuthenticationSignal.d.ts +0 -2
|
@@ -4,5 +4,5 @@ declare const flatRate: ShippingMethod;
|
|
|
4
4
|
declare const freeShipping: ShippingMethod;
|
|
5
5
|
declare const standardShipping: ShippingMethod;
|
|
6
6
|
declare const expressShipping: ShippingMethod;
|
|
7
|
-
export { flatRate, freeShipping, standardShipping
|
|
7
|
+
export { expressShipping, flatRate, freeShipping, standardShipping };
|
|
8
8
|
//# sourceMappingURL=fixtures.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const CHECKOUT_DATA_FRAGMENT = "\n fragment CheckoutData on Cart {\n is_virtual\n email\n total_quantity\n billing_address {\n city\n country {\n code\n label\n }\n firstname\n lastname\n company\n postcode\n vat_id\n region {\n region_id\n code\n label\n }\n street\n telephone\n custom_attributes {\n ... on AttributeValue {\n code\n value\n }\n }\n }\n shipping_addresses {\n firstname\n lastname\n company\n street\n city\n postcode\n vat_id\n region {\n region_id\n code\n label\n }\n country {\n code\n label\n }\n telephone\n custom_attributes {\n ... on AttributeValue {\n code\n value\n }\n }\n available_shipping_methods {\n amount {\n currency\n value\n }\n available\n carrier_code\n carrier_title\n error_message\n method_code\n method_title\n price_excl_tax {\n value\n currency\n }\n price_incl_tax {\n value\n currency\n }\n }\n selected_shipping_method {\n amount {\n value\n currency\n }\n carrier_code\n carrier_title\n method_code\n method_title\n }\n }\n available_payment_methods {\n code\n title\n }\n selected_payment_method {\n code\n title\n }\n }\n";
|
|
1
|
+
export declare const CHECKOUT_DATA_FRAGMENT = "\n fragment CheckoutData on Cart {\n is_virtual\n email\n total_quantity\n billing_address {\n city\n country {\n code\n label\n }\n firstname\n lastname\n company\n postcode\n vat_id\n region {\n region_id\n code\n label\n }\n street\n telephone\n custom_attributes {\n ... on AttributeValue {\n code\n value\n }\n }\n }\n shipping_addresses {\n firstname\n lastname\n company\n street\n city\n postcode\n vat_id\n region {\n region_id\n code\n label\n }\n country {\n code\n label\n }\n telephone\n custom_attributes {\n ... on AttributeValue {\n code\n value\n }\n }\n available_shipping_methods {\n amount {\n currency\n value\n }\n available\n carrier_code\n carrier_title\n error_message\n method_code\n method_title\n price_excl_tax {\n value\n currency\n }\n price_incl_tax {\n value\n currency\n }\n }\n selected_shipping_method {\n amount {\n value\n currency\n }\n carrier_code\n carrier_title\n method_code\n method_title\n price_excl_tax {\n value\n currency\n }\n price_incl_tax {\n value\n currency\n }\n }\n }\n available_payment_methods {\n code\n title\n }\n selected_payment_method {\n code\n title\n }\n }\n";
|
|
2
2
|
export declare const getCartQuery: string;
|
|
3
3
|
export declare const getCustomerCartQuery: string;
|
|
4
4
|
//# sourceMappingURL=getCart.graphql.d.ts.map
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const getCountries: () => Promise<CountryModel[] | undefined>;
|
|
1
|
+
export declare const getCountries: () => Promise<import('../../data/models/country').Country[] | undefined>;
|
|
4
2
|
//# sourceMappingURL=getCountries.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const getStoreConfigQuery = "\n query getStoreConfig {\n storeConfig {\n countries_with_required_region\n default_country\n display_state_if_optional\n is_guest_checkout_enabled\n is_one_page_checkout_enabled\n locale\n optional_zip_countries\n store_code\n }\n }\n";
|
|
1
|
+
export declare const getStoreConfigQuery = "\n query getStoreConfig {\n storeConfig {\n countries_with_required_region\n default_country\n display_state_if_optional\n is_guest_checkout_enabled\n is_one_page_checkout_enabled\n locale\n optional_zip_countries\n shopping_cart_display_shipping\n store_code\n }\n }\n";
|
|
2
2
|
//# sourceMappingURL=getStoreConfig.graphql.d.ts.map
|
package/api/index.d.ts
CHANGED
|
@@ -3,14 +3,18 @@ export * from './estimateShippingMethods';
|
|
|
3
3
|
export * from './fetch-graphql';
|
|
4
4
|
export * from './fetchAddressFormFields';
|
|
5
5
|
export * from './getCart';
|
|
6
|
+
export * from './getCheckoutData';
|
|
6
7
|
export * from './getCountries';
|
|
7
8
|
export * from './getCustomer';
|
|
8
9
|
export * from './getRegions';
|
|
9
10
|
export * from './getStoreConfig';
|
|
10
11
|
export * from './initialize';
|
|
12
|
+
export * from './initializeCheckout';
|
|
11
13
|
export * from './isEmailAvailable';
|
|
12
14
|
export * from './placeOrder';
|
|
13
15
|
export * from './redirect';
|
|
16
|
+
export * from './resetCheckout';
|
|
17
|
+
export * from './resetCustomer';
|
|
14
18
|
export * from './setBillingAddress';
|
|
15
19
|
export * from './setGuestEmailOnCart';
|
|
16
20
|
export * from './setPaymentMethod';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const placeOrderMutation = "\n mutation placeOrder($cartId: String!) {\n placeOrder(input: { cart_id: $cartId }) {\n orderV2 {\n number\n token\n applied_coupons {\n code\n }\n email\n id\n total {\n grand_total {\n value\n }\n subtotal {\n value\n }\n total_shipping {\n value\n }\n total_tax {\n value\n }\n }\n shipping_method\n payment_methods {\n name\n type\n }\n items {\n id\n discounts {\n amount {\n value\n }\n }\n product {\n __typename\n canonical_url\n image {\n url\n }\n name\n sku\n uid\n }\n selected_options {\n label\n value\n }\n product_sale_price {\n value\n currency\n }\n quantity_canceled\n quantity_invoiced\n quantity_ordered\n quantity_refunded\n quantity_returned\n quantity_shipped\n }\n }\n }\n }\n";
|
|
1
|
+
export declare const placeOrderMutation = "\n mutation placeOrder($cartId: String!) {\n placeOrder(input: { cart_id: $cartId }) {\n orderV2 {\n number\n status\n token\n is_virtual\n applied_coupons {\n code\n }\n email\n id\n total {\n grand_total {\n currency\n value\n }\n subtotal {\n currency\n value\n }\n total_shipping {\n currency\n value\n }\n total_tax {\n currency\n value\n }\n }\n shipping_method\n payment_methods {\n name\n type\n }\n billing_address {\n firstname\n middlename\n lastname\n street\n city\n postcode\n telephone\n country_code\n region\n region_id\n company\n custom_attributesV2 {\n code\n ... on AttributeValue {\n value\n }\n }\n }\n shipping_address {\n firstname\n middlename\n lastname\n street\n city\n postcode\n telephone\n country_code\n region\n region_id\n company\n custom_attributesV2 {\n code\n ... on AttributeValue {\n value\n }\n }\n }\n items {\n __typename\n id\n discounts {\n amount {\n value\n }\n }\n product {\n __typename\n canonical_url\n image {\n url\n }\n thumbnail {\n label\n url\n }\n name\n sku\n uid\n price_range {\n maximum_price {\n regular_price {\n currency\n value\n }\n }\n }\n }\n selected_options {\n label\n value\n }\n product_sale_price {\n value\n currency\n }\n quantity_canceled\n quantity_invoiced\n quantity_ordered\n quantity_refunded\n quantity_returned\n quantity_shipped\n ... on GiftCardOrderItem {\n gift_card {\n recipient_name\n recipient_email\n sender_name\n sender_email\n message\n }\n }\n }\n }\n }\n }\n";
|
|
2
2
|
//# sourceMappingURL=placeOrder.graphql.d.ts.map
|
|
@@ -25,6 +25,10 @@ declare const signalTypes: {
|
|
|
25
25
|
data?: import('../../data/models/store-config').StoreConfig | undefined;
|
|
26
26
|
pending: boolean;
|
|
27
27
|
}>;
|
|
28
|
+
countryList: import('@preact/signals-core').Signal<{
|
|
29
|
+
data?: import('../../data/models/country').Country[] | undefined;
|
|
30
|
+
pending: boolean;
|
|
31
|
+
}>;
|
|
28
32
|
};
|
|
29
33
|
type SignalTypesType = typeof signalTypes;
|
|
30
34
|
type SignalTypesKeys = keyof SignalTypesType;
|
package/api.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as
|
|
1
|
+
import{D as g,F as h,I as l,c,M as f,d as C,a as x,b as A,S as F,U as u,j as E,i as M,g as S,h as T,k as D,r as G,s as O,e as U,f as R}from"./chunks/fixtures.js";import{e as k,g as I}from"./chunks/getMultilineValues.js";import{g as _,a as v,b as y}from"./chunks/getCustomer.js";import{c as H,g as N,i as w,a as z,r as L,b as P}from"./chunks/resetCustomer.js";import{i as Y,s as q}from"./chunks/setGuestEmailOnCart.js";import{p as K}from"./chunks/placeOrder2.js";import{s as W}from"./chunks/setBillingAddress.js";import{s as Z}from"./chunks/setPaymentMethod.js";import{S as ss,p as es,s as as}from"./chunks/setShippingAddress.js";import{s as rs}from"./chunks/setShippingMethods.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/getCart.graphql.js";import"@dropins/tools/lib.js";const n=e=>{var s;(s=window==null?void 0:window.location)==null||s.assign(e)};export{g as DEFAULT_COUNTRY,h as FetchError,l as InvalidArgument,c as MissingBillingAddress,f as MissingCart,C as MissingCountry,x as MissingEmail,A as MissingPaymentMethod,ss as STANDARD_ATTRIBUTES,F as STORE_CONFIG_DEFAULTS,u as UnexpectedError,H as config,E as defaultFormFields,k as estimateShippingMethods,M as fetchAddressFormFields,S as fetchGraphQl,_ as getCart,v as getCheckoutData,T as getConfig,N as getCountries,y as getCustomer,I as getRegions,D as getStoreConfig,w as initialize,z as initializeCheckout,Y as isEmailAvailable,K as placeOrder,es as prepareAddress,n as redirect,G as removeFetchGraphQlHeader,L as resetCheckout,P as resetCustomer,W as setBillingAddress,O as setEndpoint,U as setFetchGraphQlHeader,R as setFetchGraphQlHeaders,q as setGuestEmailOnCart,Z as setPaymentMethod,as as setShippingAddress,rs as setShippingMethodsOnCart};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@dropins/tools/event-bus.js";import{
|
|
1
|
+
import"@dropins/tools/event-bus.js";import{l as p,n as f}from"./fixtures.js";import{s as k}from"./setBillingAddress.js";import{classes as b}from"@dropins/tools/lib.js";import{Checkbox as S,Skeleton as _,SkeletonRow as A}from"@dropins/tools/components.js";/* empty css */import{jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{useText as v}from"@dropins/tools/i18n.js";import{useState as B,useEffect as g}from"@dropins/tools/preact-compat.js";import{u as I}from"./address-form-fields.js";const x=({className:r,isInitialized:s=!0,checked:i=!0,...t})=>{const e=v({title:"Checkout.BillToShippingAddress.title"});return s?o("div",{className:b(["checkout-bill-to-shipping-address",r]),children:o(S,{"data-testid":"bill-to-shipping-checkbox",className:"checkout-bill-to-shipping-address__checkbox",checked:i,name:"checkout-bill-to-shipping-address__checkbox",label:e.title,...t})}):o(C,{})},C=()=>o(_,{className:"bill-to-shipping-address__skeleton",children:o(A,{variant:"row",size:"small"})}),m="is_bill_to_shipping_address";function y(r,s,i){const t=r[i],e=s[i];return t===void 0&&e===void 0||t===null&&e===null?!0:typeof t=="object"&&typeof e=="object"?JSON.stringify(t)===JSON.stringify(e):t===e}function N(r,s,i){return!s&&!i?!0:!s||!i?!1:r.every(t=>{const e=t.code;return y(s,i,e)})}const T=({isBillToShipping:r})=>{var d;const[s,i]=B(!1),{fields:t}=I(),e=f.value.data,h=(e==null?void 0:e.id)||"",l=!!e,c=e==null?void 0:e.billingAddress,n=(d=e==null?void 0:e.shippingAddresses)==null?void 0:d[0],a=!!n;return g(()=>{if(s)return;const u=localStorage.getItem(m);u&&(i(!0),r.value={checked:u==="true",setByUser:!1})},[s,r]),g(()=>{if(s||!t||!l)return;i(!0);const u=N(t,c,n);r.value={checked:c?u:r.value.checked,setByUser:!1}},[c,t,l,r,s,n]),{cartId:h,isInitialized:s,hasShippingAddress:a}},P=({children:r,...s})=>{const i=p.value.checked,{hasShippingAddress:t,isInitialized:e}=T({isBillToShipping:p});return o(x,{...s,checked:i,isInitialized:e,onChange:l=>{const n=l.target.checked;if(p.value={checked:n,setByUser:!0},localStorage.setItem(m,n.toString()),!e||!n||!t)return;const a=new AbortController;return k({signal:a.signal,input:{same_as_shipping:!0}}).catch(d=>{console.error(d)}),()=>{a.abort()}},disabled:f.value.pending})};export{P as B,m as a,N as c};
|
package/chunks/BillingForm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@dropins/tools/event-bus.js";import{
|
|
1
|
+
import"@dropins/tools/event-bus.js";import{m as A,n as B,l as F}from"./fixtures.js";import{A as b}from"./getMultilineValues.js";import{s as h}from"./setBillingAddress.js";import{p as v}from"./setShippingAddress.js";import{A as I}from"./ToggleButton.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/lib.js";import{c as y}from"./BillToShippingAddress2.js";import{u as S}from"./address-form-fields.js";import{useRef as k,useMemo as L,useCallback as _,useEffect as C}from"@dropins/tools/preact-compat.js";import{jsx as M}from"@dropins/tools/preact-jsx-runtime.js";import{B as N}from"./constants2.js";const D=u=>{var f;const l=k(null),{fields:i}=S(),o=A.value.data,n=o==null?void 0:o.defaultBillingAddress,s=B.value.data,a=(s==null?void 0:s.id)||"",t=s==null?void 0:s.billingAddress,m=(f=s==null?void 0:s.shippingAddresses)==null?void 0:f[0],{checked:r,setByUser:p}=F.value,d=!r,g=L(()=>!i||!d?!1:t?!y(i,t,m):!!n,[d,i,t,m,n]),c=_(e=>h({signal:e.signal,cartId:a,input:{address:r?void 0:v(e.address),same_as_shipping:r}}),[a,r]);return C(()=>{if(!p)return;const e=new AbortController;return r||l.current.triggerSaveAddress(e.signal),()=>{e.abort()}},[r,p]),M(I,{...u,addressType:b.BILLING,autoFill:g,"data-testid":"billing-form",headingId:"Checkout.BillingAddress.title",name:N,ref:l,saveAddressHandler:c,style:{display:d?"block":"none"}})};export{D as B};
|
package/chunks/LoginForm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@dropins/tools/event-bus.js";import{
|
|
1
|
+
import"@dropins/tools/event-bus.js";import{n as T,m as B}from"./fixtures.js";import{i as z,s as V}from"./setGuestEmailOnCart.js";import{H as $,p as j}from"./ToggleButton.js";import{useState as f,useEffect as q}from"@dropins/tools/preact-hooks.js";import{classes as N}from"@dropins/tools/lib.js";import{Field as G,Input as O,Divider as P}from"@dropins/tools/components.js";/* empty css */import{jsx as i,jsxs as c,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{useText as k,Text as F}from"@dropins/tools/i18n.js";import{L as R}from"./constants3.js";const U=({value:o,error:l,hint:t,onChange:u,onBlur:d,onInvalid:n})=>{const e=k({LoginFormLabel:"Checkout.LoginForm.ariaLabel",LoginFormFloatingLabel:"Checkout.LoginForm.floatingLabel",LoginFormPlaceholder:"Checkout.LoginForm.placeholder"});return i(G,{size:"medium",error:l,hint:t,children:i(O,{id:"customer-email",name:"customer-email",type:"email",value:o,autocomplete:"email",placeholder:e.LoginFormPlaceholder,floatingLabel:e.LoginFormFloatingLabel,onChange:u,onBlur:d,onInvalid:n,required:!0,"aria-label":e.LoginFormLabel,"aria-required":!0})})},J=({onSignInClick:o,email:l})=>c("div",{className:"checkout-login-form__sign-in",children:[i(F,{id:"Checkout.LoginForm.account"}),i("a",{"data-testid":"sign-in-link",className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t=>{t.preventDefault(),o==null||o(l)},children:i(F,{id:"Checkout.LoginForm.signIn"})})]}),K=({name:o,className:l,currentEmail:t,hint:u,error:d=null,onEmailChange:n,onEmailBlur:e,onEmailInvalid:L,onSignInClick:v,onSignOutClick:p,customer:a,...s})=>{const h=k({Title:"Checkout.LoginForm.title"}),g=!!a;return c("div",{...s,className:N(["checkout-login-form",l]),"data-testid":"checkout-login-form",children:[c("div",{className:"checkout-login-form__heading",children:[i($,{level:2,className:"checkout-login-form__title",children:h.Title}),g?i(Q,{onSignOutClick:p}):i(J,{onSignInClick:v,email:t})]}),a?c("div",{className:"checkout-login-form__customer-details",children:[i("div",{className:"checkout-login-form__customer-name",children:`${a==null?void 0:a.firstName} ${a==null?void 0:a.lastName}`}),i("div",{className:"checkout-login-form__customer-email",children:a==null?void 0:a.email})]}):i("div",{className:"checkout-login-form__content",children:c("form",{className:N(["dropin-login-form__form",l]),name:o,noValidate:!0,children:[i("button",{type:"submit",disabled:!0,style:"display: none","aria-hidden":"true"}),i(U,{value:t||void 0,error:d||"",hint:u,onChange:n,onBlur:e,onInvalid:L})]})}),i(P,{variant:"primary"})]})},Q=({onSignOutClick:o})=>c("p",{className:"checkout-login-form__sign-out",children:[i(F,{id:"Checkout.LoginForm.switch"}),i("a",{className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:l=>{l.preventDefault(),o==null||o()},children:i(F,{id:"Checkout.LoginForm.signOut"})})]}),W=o=>j.email.test(o),X=1e3,se=({className:o,email:l=null,onSignInClick:t,onSignOutClick:u,...d})=>{const n=k({LoginFormInvalidEmailError:"Checkout.LoginForm.invalidEmailError",LoginFormMissingEmailError:"Checkout.LoginForm.missingEmailError",LoginFormEmailExistsAlreadyHaveAccount:"Checkout.LoginForm.emailExists.alreadyHaveAccount",LoginFormEmailExistsSignInButton:"Checkout.LoginForm.emailExists.signInButton",LoginFormEmailExistsForFasterCheckout:"Checkout.LoginForm.emailExists.forFasterCheckout"}),{data:e}=T.value,L=(e==null?void 0:e.id)||"",v=!!e,[p,a]=f(!1),[s,h]=f(l),[g,E]=f(),[x,_]=f(!0),b=r=>r.valid?null:r.valueMissing?n.LoginFormMissingEmailError:n.LoginFormInvalidEmailError,C=B.value.data,y=r=>{const{value:m}=r.target;h(m),E(null),_(!0)},A=r=>{const{validity:m}=r.target;E(b(m))},I=r=>{const{validity:m}=r.target;E(b(m))};!p&&v&&(a(!0),h((e==null?void 0:e.email)||l)),q(()=>{if(!s||g)return;const r=setTimeout(()=>{z(s).then(m=>{_(m),(e==null?void 0:e.email)!==s&&V(s).catch(M=>{console.log("set email failed",M)})}).catch(m=>{console.log(m),E(n.LoginFormInvalidEmailError),_(!0)})},X);return()=>{r&&clearTimeout(r)}},[s,g,n.LoginFormInvalidEmailError,e==null?void 0:e.email,L]);const H=x?"":c(w,{children:[n.LoginFormEmailExistsAlreadyHaveAccount," ",i("a",{href:"#",onClick:r=>{r.preventDefault(),t==null||t(s)},children:n.LoginFormEmailExistsSignInButton})," ",n.LoginFormEmailExistsForFasterCheckout]});return i(K,{className:o,currentEmail:s,error:g,hint:H,name:R,onEmailBlur:A,onEmailChange:y,onEmailInvalid:I,onSignInClick:r=>{const m=s?W(s):!1;t==null||t(m?r:null)},onSignOutClick:u,customer:C,...d})};export{se as L};
|
package/chunks/PlaceOrder.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{classes as c}from"@dropins/tools/lib.js";import"./ToggleButton.js";import{Button as l}from"@dropins/tools/components.js";import{jsx as i}from"@dropins/tools/preact-jsx-runtime.js";import{Text as a}from"@dropins/tools/i18n.js";import"@dropins/tools/event-bus.js";import{
|
|
1
|
+
import{classes as c}from"@dropins/tools/lib.js";import"./ToggleButton.js";import{Button as l}from"@dropins/tools/components.js";import{jsx as i}from"@dropins/tools/preact-jsx-runtime.js";import{Text as a}from"@dropins/tools/i18n.js";import"@dropins/tools/event-bus.js";import{n as s}from"./fixtures.js";/* empty css */import"@dropins/tools/preact-compat.js";import"./address-form-fields.js";import"@dropins/tools/preact-hooks.js";import{B as m}from"./constants2.js";import{L as d}from"./constants3.js";import{S as f}from"./constants.js";const p=({className:e,children:o,...t})=>{const{onClick:r=()=>{},isLoading:n}=t;return i("div",{className:c(["checkout-place-order",e]),children:i(l,{className:c(["checkout-place-order__button",e]),size:"medium",variant:"primary",type:"submit",onClick:r,disabled:n,children:i(a,{id:"Checkout.PlaceOrder.button"})},"placeOrder")})},u=[d,f,m],h=e=>{const o=e.querySelector(":invalid");o&&(o.scrollIntoView({behavior:"smooth"}),o.focus())},O=()=>{const o=(Array.from(document.forms)||[]).filter(r=>u.includes(r.name)).filter(r=>r.offsetParent!==null).filter(r=>!r.checkValidity()),t=o.length===0;if(!t){const r=o[0];h(r)}return t},E=e=>{const{onClick:o,handleServerError:t}=e;return i(p,{onClick:async()=>{if(O())try{await o()}catch(n){t(n)}},isLoading:s.value.pending})};export{E as P};
|
package/chunks/ShippingForm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@dropins/tools/event-bus.js";import{
|
|
1
|
+
import"@dropins/tools/event-bus.js";import{l as o}from"./fixtures.js";import{A as t}from"./getMultilineValues.js";import{s as a}from"./setBillingAddress.js";import{s as d,p as m}from"./setShippingAddress.js";import{A as n}from"./ToggleButton.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/lib.js";import{useCallback as l}from"@dropins/tools/preact-compat.js";import{jsx as g}from"@dropins/tools/preact-jsx-runtime.js";import{S as h}from"./constants.js";const B=({preselectedFields:i,...e})=>{const s=o.value.checked,p=l(r=>d({signal:r.signal,address:m(r.address)}).then(()=>{if(s)return a({input:{same_as_shipping:!0}})}),[s]);return g(n,{...e,addressType:t.SHIPPING,headingId:"Checkout.ShippingAddress.title",name:h,preselectedFields:i,saveAddressHandler:p})};export{B as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as
|
|
1
|
+
import{e as R}from"./getMultilineValues.js";import{x as B,y as L,n as b,q as O,z as P}from"./fixtures.js";import{events as T}from"@dropins/tools/event-bus.js";import{s as q}from"./setShippingMethods.js";import{classes as H}from"@dropins/tools/lib.js";import{H as D}from"./ToggleButton.js";import{IllustratedMessage as V,Icon as Z,ProgressSpinner as $,RadioButton as F,Price as G,Divider as J,Skeleton as K,SkeletonRow as _}from"@dropins/tools/components.js";import{useState as w,useEffect as y}from"@dropins/tools/preact-hooks.js";/* empty css */import{jsx as i,jsxs as x,Fragment as Q}from"@dropins/tools/preact-jsx-runtime.js";import*as c from"@dropins/tools/preact-compat.js";import{useCallback as U,useMemo as X,useEffect as I}from"@dropins/tools/preact-compat.js";import{useText as Y}from"@dropins/tools/i18n.js";const k=B(void 0),ee=e=>({countryCode:e.country_id,postCode:e.postcode||"",...e.region_id?{regionId:Number(e.region_id)}:{...e.region?{region:e.region}:{}}}),te=e=>({carrierCode:e.carrier.code||"",methodCode:e.code||"",amount:e.amount,amountExclTax:e.amountExclTax,amountInclTax:e.amountInclTax}),ne=e=>c.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},c.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"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),c.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"}),c.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"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),c.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),oe=({className:e,isLoading:n=!1,onSelectionChange:a=()=>{},options:o,selection:r,...d})=>{const u=Y({Title:"Checkout.ShippingMethods.title",EmptyState:"Checkout.ShippingMethods.emptyState"});return o===void 0?i(ie,{}):x("div",{...d,className:H(["checkout-shipping-methods",e]),children:[i(D,{level:3,className:"checkout-shipping-methods__title",children:u.Title}),!n&&o.length===0&&i(V,{icon:i(Z,{source:ne}),message:i("p",{children:u.EmptyState})}),x("div",{className:H(["checkout-shipping-methods__content"]),children:[n&&i($,{className:"checkout-shipping-methods__spinner"}),i("div",{className:H(["checkout-shipping-methods__options",["checkout-shipping-methods__options--loading",n]]),children:o.map(t=>i(F,{"data-testid":"shipping-method-radiobutton","aria-busy":n,id:t.value,name:"shipping-method",className:"checkout-shipping-methods__method",label:x(Q,{children:[i(G,{amount:t.amount.value,currency:t.amount.currency})," ",i("span",{children:t.carrier.title})]}),description:t.title,value:t.value,checked:(r==null?void 0:r.value)===t.value,onChange:()=>a(t)},t.value))})]}),i(J,{variant:"primary"})]})},ie=()=>x(K,{"data-testid":"shipping-methods-skeleton",children:[i(_,{variant:"heading",size:"small"}),i(_,{variant:"empty",size:"small"}),i(_,{size:"medium",fullWidth:!0}),i(_,{size:"medium",fullWidth:!0})]}),W=(e,n)=>e.code===n.code&&e.carrier.code===n.carrier.code;function re(){var S;const[e,n]=w(),[a,o]=w();y(()=>{T.on("checkout/address",({address:C,type:g})=>{g==="shipping"&&n(C)})},[]),y(()=>{o(k.value)},[k.value]),y(()=>{L.value.pending?o(void 0):o(k.value)},[L.value.pending]);const{country_id:r,region_id:d,region:u,postcode:t}=e||{},v=!!e,h=b.value.data,s=!!((S=h==null?void 0:h.shippingAddresses)!=null&&S[0]);y(()=>{s||!a||!v||T.emit("shipping/estimate",{address:ee({country_id:r,region_id:d,region:u,postcode:t}),shippingMethod:te(a)})},[a,r,d,u,t,v,s])}function se(e){const n=O.value.data,a=!n,o=b.value.data,r=b.value.pending,d=L.value.data,u=L.value.pending,t=k.value,v=o==null?void 0:o.id,h=o==null?void 0:o.shippingAddresses,s=h==null?void 0:h[0],S=!!s,C=s==null?void 0:s.availableShippingMethods,g=s==null?void 0:s.selectedShippingMethod,l=C||d,N=U(p=>{if(!S)return;const f={method_code:p.code,carrier_code:p.carrier.code};q([f]).catch(M=>{console.error("setting shipping methods on cart failed:",M)})},[S]),A=p=>{k.value=p},m=X(()=>{if(!(l!=null&&l.length))return;const p=l[0],f=t||g;return f?l.some(E=>W(E,f))?f:p:l.find(j=>j.carrier.code===(e==null?void 0:e.carrierCode)&&j.code===(e==null?void 0:e.methodCode))||p},[t,g,l,e]);return I(()=>{m&&((!t||!W(m,t))&&(k.value=m),(!g||!W(m,g))&&N(m))},[m,t,g,N]),I(()=>{if(!v||C)return;const{country:p,selectedRegion:f,selectedRegionId:M}=P.value,E=p||(n==null?void 0:n.defaultCountry);E&&R({criteria:{country_code:E,region_name:f,region_id:M}}).catch(z=>{L.value={pending:!1,data:[]},console.error("shipping methods estimation failed:",z)})},[v,C,n]),{isLoading:r||a||u,options:l,selection:m,onSelectionChange:A}}const Se=({preSelectedMethod:e,...n})=>{const{isLoading:a,options:o,selection:r,onSelectionChange:d}=se(e);return re(),i(oe,{...n,className:"checkout-shipping-methods",isLoading:a,onSelectionChange:d,options:o,selection:r})};export{Se as S};
|
package/chunks/ToggleButton.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{events as te}from"@dropins/tools/event-bus.js";import{A as P,x as L,m as re,V as y,w as me,l as fe}from"./fixtures.js";import{b as J,a as p,A as R,e as ge,D as U,g as he,M as K,c as Q}from"./address-form-fields.js";import{useState as q,useEffect as z,useCallback as V,useRef as Fe,useMemo as pe}from"@dropins/tools/preact-hooks.js";import{u as ve}from"./address-form-fields2.js";import{d as Ie,e as Ee}from"./services.js";import{classes as B,getFormErrors as Ce,VComponent as _}from"@dropins/tools/lib.js";import{Text as ne,useText as Ae}from"@dropins/tools/i18n.js";import{Field as Z,Input as oe,Picker as be,Skeleton as Se,SkeletonRow as S,ProgressSpinner as ke}from"@dropins/tools/components.js";/* empty css */import{jsx as a,Fragment as ae,jsxs as O}from"@dropins/tools/preact-jsx-runtime.js";import{forwardRef as Me,useRef as $e,useImperativeHandle as Re,useState as j,useEffect as W}from"@dropins/tools/preact-compat.js";import{E as Le}from"./ErrorBanner.js";import{M as ye}from"./MergedCartBanner.js";const X={firstname:"given-name",lastname:"family-name",company:"organization",country:"country",region:"address-level1",city:"address-level2",postcode:"postal-code",telephone:"tel",street:"address-line1",email:"email",middlename:"additional-name",prefix:"honorific-prefix",suffix:"honorific-suffix"};function se(e){return Object.keys(e).length===0&&e.constructor===Object}const De=e=>e.map(t=>{var o;const r=((o=t==null?void 0:t.id)==null?void 0:o.toString())||t.code;return{text:t.name,value:r}}),we=e=>e?e.map(t=>({text:t.label,value:t.value})):[];function Ne({address:e,addressType:t,availableCountries:r,availableRegions:o,config:s,dismissError:u,errors:n,fields:d,onBlur:f,onChange:v,onInvalid:i,onSelection:h,setAddress:E}){const F=()=>{E(c=>({...c,[p.Region]:"",[p.RegionId]:""})),u(p.Region)},C=c=>{E(b=>({...b,[p.RegionId]:c}))};return d.map(c=>{var I;let b,m=c.frontendInput,A=h,D=v,w=c.isDisabled,N=c.isRequired,k=[],l;return m===P.Multiline?(l=J(c.code,e),b=J(c.code,n)):(l=e[c.code],b=n[c.code]||""),c.code===p.Country&&(k=we(r),t===R.SHIPPING&&(L.value.country=l,A=g=>{const M=g.target,{value:$}=M;$&&T({country_code:$}),h(g),F()})),c.code===p.RegionId&&t===R.SHIPPING&&(L.value.selectedRegionId=l),c.code===p.Region&&(t===L.value.addressType&&(w=L.value.pending),N=s.countriesWithRequiredRegion.includes(e==null?void 0:e.country_id),k=De(o),!N&&!s.displayStateIfOptional&&(m=P.Undefined),m=k.length>0?P.Select:P.Text,m===P.Select?t===R.SHIPPING?(L.value.selectedRegion=l,A=g=>{const $=g.target.value;T({country_code:L.value.country,region_id:$}),h(g),C($)}):A=g=>{h(g);const $=g.target.value;C($)}:m===P.Text&&t===R.SHIPPING&&(L.value.selectedRegion=l,D=g=>{const M=g.target,{value:$}=M;L.value.country&&T({country_code:L.value.country,region_name:$}),v(g)}),l=k.length>0?((I=k.find(g=>g.value===l))==null?void 0:I.value)||"":l),c.code===p.PostCode&&(N=!s.countriesWithOptionalZipCode.includes(e==null?void 0:e.country_id)),{...c,error:b,frontendInput:m,handleSelect:A,isDisabled:w,isRequired:N,onBlur:f,onChange:D,onInvalid:i,options:k,value:l}})}let ee;function T(e){var u;const t=re.value.data,r=!!t,o=(u=t==null?void 0:t.shippingAddresses)==null?void 0:u[0],s=o==null?void 0:o.availableShippingMethods;r&&!s&&(clearTimeout(ee),ee=setTimeout(()=>{ge({criteria:e})},U))}const G=({addressType:e,code:t,index:r})=>r?`${e}-${t}-${r}`:`${e}-${t}`,H=e=>`checkout-address-form__${e}`,_e=({addressType:e,element:t})=>{const{code:r,value:o,defaultValue:s}=t;return a("input",{className:H(r),id:G({addressType:e,code:r}),name:r,type:"hidden",value:o||s},r)},xe=({addressType:e,element:t})=>{const{code:r,error:o,isDisabled:s,label:u,onBlur:n,onChange:d,onInvalid:f,validateRules:v,value:i}=t,h=ie(v);return a(Z,{disabled:s,error:o,children:a(oe,{"aria-label":u,autocomplete:X[r]||"off",className:H(r),floatingLabel:`${u} ${t.isRequired?"*":""}`,id:G({addressType:e,code:r}),onBlur:n,onChange:d,onInvalid:f,placeholder:u,required:t.isRequired||!1,type:"text",name:r,value:i??void 0,...h})})},ze=({addressType:e,element:t})=>{const{code:r,error:o,isDisabled:s,isRequired:u,label:n,multilineCount:d,onBlur:f,onChange:v,onInvalid:i,validateRules:h,value:E}=t,F=d??0,C=ie(h);return a(ae,{children:Array.from(Array(F).keys()).map(c=>a(Z,{disabled:s,error:(o==null?void 0:o[c])||"",className:"dropin-field--multiline",children:a(oe,{id:G({addressType:e,code:r,index:c}),className:H(r),floatingLabel:`${n} ${c!=0?c:""} ${u&&c===0?"*":""}`,autocomplete:c===0?X[r]:"off","aria-label":n,placeholder:`${n} ${c!=0?c:""}`,type:"text",required:u&&c===0,onChange:v,onBlur:f,onInvalid:i,name:`${r}-${c}`,value:(E==null?void 0:E[c])||void 0,...C})},`${r}-${c}`))})},Pe=({addressType:e,element:t})=>{const{code:r,error:o,handleSelect:s,isDisabled:u,isRequired:n,label:d,onBlur:f,onInvalid:v,options:i,value:h}=t,E=s?{handleSelect:s}:{};return a(Z,{disabled:u,error:o,children:a(be,{id:G({addressType:e,code:r}),className:H(r),name:r,floatingLabel:`${d} ${n?"*":""}`,required:n,placeholder:d,"aria-label":d,options:i,value:h,autocomplete:X[r]||"off",onBlur:f,onInvalid:v,...E},r)})},Ve=({addressType:e,element:t})=>{switch(t.frontendInput){case"BOOLEAN":case"DATE":case"DATETIME":case"FILE":case"GALLERY":case"IMAGE":case"MEDIA_IMAGE":case"MULTISELECT":case"PRICE":case"TEXTAREA":case"UNDEFINED":case"WEIGHT":return null;case"HIDDEN":return _e({addressType:e,element:t});case"TEXT":return xe({addressType:e,element:t});case"MULTILINE":return ze({addressType:e,element:t});case"SELECT":return Pe({addressType:e,element:t});default:return null}},ie=e=>e?e.reduce((t,r)=>{switch(r.name){case y.DateRangeMax:return{...t,max:r.value};case y.DateRangeMin:return{...t,min:r.value};case y.FileExtensions:return{...t,accept:r.value};case y.InputValidation:return{...t,pattern:Oe(r.value)};case y.MaxFileSize:case y.MaxImageHeight:case y.MaxImageWidth:return t;case y.MaxTextLength:return{...t,maxLength:r.value};case y.MinTextLength:return{...t,minLength:r.value};default:throw new Error(`Unknown rule: ${r.name}`)}},{}):{},x={alpha:/^[a-zA-Z]+$/,alphanumeric:/^[a-zA-Z0-9]+$/,"alphanumeric-w-space":/^[a-zA-Z0-9 ]+$/,"alphanum-with-spaces":/^[a-zA-Z0-9 ]+$/,email:/^([a-z0-9,!#$%&'*+/=?^_`{|}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!#$%&'*+/=?^_`{|}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i,numeric:/^[0-9]+$/,url:/^((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w\-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\\w]*))?)$/},Oe=e=>{switch(e){case"alpha":return x.alpha.source;case"alphanumeric":return x.alphanumeric.source;case"alphanumeric-w-space":return x["alphanumeric-w-space"].source;case"alphanum-with-spaces":return x["alphanum-with-spaces"].source;case"url":return x.url.source;case"numeric":return x.numeric.source;case"email":return x.email.source;default:throw new Error(`Unknown validation type: ${e}`)}},Be=e=>O(Se,{...e,children:[a(S,{variant:"heading",size:"medium"}),a(S,{variant:"empty",size:"medium"}),a(S,{size:"large"}),a(S,{size:"large"}),a(S,{size:"large",fullWidth:!0}),a(S,{size:"large",fullWidth:!0,lines:3}),a(S,{size:"large"}),a(S,{size:"large"}),a(S,{size:"large"}),a(S,{size:"large"}),a(S,{size:"large"}),a(S,{size:"large"}),a(S,{size:"large"})]}),Ue=({addressType:e,className:t,fields:r,formRef:o,headingId:s,name:u,...n})=>O("div",{...n,className:B(["checkout-fields-form",t]),children:[a(ce,{level:2,children:a(ne,{id:s}),className:"checkout-fields-form__title"}),a("form",{name:u,ref:o,className:B(["checkout-fields-form__form",t]),noValidate:!0,children:r.sort((d,f)=>!d.sortOrder||!f.sortOrder?d.code<f.code?-1:1:d.sortOrder-f.sortOrder).map(d=>Ve({element:d,addressType:e}))})]}),Ge=e=>{const t=new FormData(e),r=Object.fromEntries(t);return Object.entries(r).reduce((s,[u])=>{const n=e.elements[u];return n!=null&&n.validationMessage?{...s,[u]:n.validationMessage}:{...s}},{})};function He(e){const[t,r]=j({});return W(()=>{e&&r(o=>({...o,country_id:e}))},[e]),{defaultValues:t}}function Te({country:e,addressType:t}){const[r,o]=j([]);return W(()=>{if(!e){o([]);return}he(e,t).then(s=>{o(s||[])}).catch(s=>{console.error(s)})},[o,e,t]),{availableRegions:r}}function qe({autoFill:e,addressType:t,dismissError:r,loadAutoFill:o}){const[s,u]=j(!1),n=fe.value.data,d=!!n,f=re.value.data,v=!!f;W(()=>{var b;if(!e||!v||s)return;let i,h=!1;i=nt({addressType:t,cart:f}),!i&&d&&(i=rt({addressType:t,customer:n}),h=!0);const E=m=>m?m.split(Q).length>1:!1;if(!i)return;u(!0);const F={[p.City]:i.city,[p.Company]:i.company||"",[p.Country]:i.country.value,[p.FirstName]:i.firstName,[p.LastName]:i.lastName,[p.PostCode]:i.postCode||"",[p.Telephone]:i.telephone||"",[p.Vat]:i.vatId||""},C=i.region;if(C){const m=(b=C==null?void 0:C.id)==null?void 0:b.toString();m?(F[p.Region]=m,F[p.RegionId]=m):F[p.Region]=C.code}i!=null&&i.street&&i.street.length>0&&i.street.forEach((m,A)=>{F[`${p.Street}${K}${A}`]=m}),((i==null?void 0:i.customAttributes)||[]).forEach(m=>{E(m.code)?m.value.split(Q).forEach((D,w)=>{F[`${m.code}${K}${w}`]=D}):F[m.code]=m.value}),o({values:F,triggerAutoSave:h})},[t,e,f,n,s,v,d,o,r])}const St=Me(({addressType:e,autoFill:t=!0,children:r,headingId:o,name:s,preselectedFields:u,saveAddressHandler:n,...d},f)=>{const{fields:v}=ve(),{countries:i}=Ie(),h=i===void 0,E=v===void 0,F=me.value.data,C=F===void 0,{defaultValues:c}=He(F==null?void 0:F.defaultCountry),b=tt({fields:v,preselectedFields:u}),m=$e(null),{address:A,errors:D,loadAutoFill:w,onBlur:N,dismissError:k,onChange:l,onInvalid:I,onSelection:g,setAddress:M}=Qe({formRef:m,type:e,defaultValues:c,preselection:b,saveAddressHandler:n}),{availableRegions:$}=Te({country:A.country_id,addressType:e});if(Re(f,()=>({triggerSaveAddress:le=>{if(!m.current)return;const de=Ge(m.current);if(se(de))return n({signal:le,address:A})}})),qe({addressType:e,autoFill:t,loadAutoFill:w,dismissError:k}),E||h||C)return a(Be,{"data-testid":`${e}-skeleton`});const ue=Ne({address:A,addressType:e,availableCountries:i,availableRegions:$,config:F,dismissError:k,errors:D,fields:v,onBlur:N,onChange:l,onInvalid:I,onSelection:g,setAddress:M}),Y={[R.SHIPPING]:"shipping",[R.BILLING]:"billing"};return a(Ue,{...d,name:s,addressType:e,className:`checkout-${Y[e]}-form`,"data-testid":`${Y[e]}-form`,fields:ue,formRef:m,headingId:o})});function Ze(e){const{backupService:t}=Ee(),[r,o]=q(null);z(()=>{const n=t.restore(e);n&&o(n)},[e,t]),z(()=>{const n=te.on("checkout/order",()=>{t.remove(e)});return()=>{n==null||n.off()}},[e,t]);const s=V(n=>setTimeout(()=>{t.backup(e,n)},U),[e,t]),u=V(()=>{t.remove(e)},[e,t]);return{addressBackup:r,backup:s,removeBackup:u}}const je={badInput:"aria-label",patternMismatch:"aria-label",rangeOverflow:"max",rangeUnderflow:"min",tooLong:"maxlength",tooShort:"minlength",typeMismatch:"aria-label",valueMissing:"aria-label"},We=["badInput","patternMismatch","rangeOverflow","rangeUnderflow","tooLong","tooShort","typeMismatch","valueMissing"],Xe=e=>{const[t,r]=q({}),o=V(n=>{const{name:d,validity:f,validationMessage:v}=n;let i=f.valid?"":v;We.forEach(h=>{if(!f[h])return;const E=e[h];if(!E)return;const F=je[h];i=E.replace("{field}",n.getAttribute(F)||"")}),r(h=>({...h,[d]:i}))},[e]);return{errors:t,dismissError:n=>{t[n]&&r(d=>{const{[n]:f,...v}=d;return v})},validateFormElement:o,resetErrors:()=>{r({})}}},Ye={[R.BILLING]:"billing",[R.SHIPPING]:"shipping"};function Je({address:e,type:t}){z(()=>{const r=setTimeout(()=>{te.emit("checkout/address",{type:Ye[t],address:e})},U);return()=>{clearTimeout(r)}},[e,t])}const Ke=e=>{const t=e.current;if(!t)return!1;const r=Ce(t);return se(r)},Qe=({formRef:e,type:t,defaultValues:r={},preselection:o={},saveAddressHandler:s})=>{const u=Ae({badInput:"Checkout.AddressForm.Validity.badInput",patternMismatch:"Checkout.AddressForm.Validity.patternMismatch",rangeUnderflow:"Checkout.AddressForm.Validity.rangeUnderflow",tooLong:"Checkout.AddressForm.Validity.tooLong",tooShort:"Checkout.AddressForm.Validity.tooShort",typeMismatch:"Checkout.AddressForm.Validity.typeMismatch",valueMissing:"Checkout.AddressForm.Validity.valueMissing"}),n=Fe(!1),[d,f]=q({});Je({address:d,type:t});const{addressBackup:v,backup:i,removeBackup:h}=Ze(t),{errors:E,validateFormElement:F,dismissError:C,resetErrors:c}=Xe(u),b=V(l=>{n.current=!1,s(l).then(()=>{h()}).catch(I=>{n.current=!0,console.error("Saving address form failed:",I)})},[h,s]),m=(l,I)=>{f(g=>({...g,[l]:I})),n.current=!0},A=({values:l,triggerAutoSave:I=!1})=>{c(),f(g=>({...g,...l})),I&&(n.current=!0)},D=l=>{const I=l.target,{name:g,value:M}=I;m(g,M),F(I)},w=l=>{const I=l.target;F(I)},N=l=>{const I=l.target,{name:g,value:M}=I;m(g,M),F(I)},k=l=>{l.target.checkValidity()};return z(()=>{f(l=>({...r,...o,...v,...l}))},[r,o,v]),z(()=>{if(!n.current)return;const l=i(d);return()=>{clearTimeout(l)}},[d,i]),z(()=>{if(!n.current||!Ke(e))return;const l=new AbortController,I=l.signal,g=setTimeout(()=>{b({signal:I,address:d})},U);return()=>{clearTimeout(g),l.abort()}},[d,e,b]),{address:d,errors:E,loadAutoFill:A,dismissError:C,onChange:D,onSelection:N,onBlur:k,onInvalid:w,setAddress:f}},et={countryCode:p.Country,region:p.Region,postCode:p.PostCode};function tt({fields:e,preselectedFields:t}){return pe(()=>!(!!e&&e.length>0)||!!!t?{}:Object.keys(t).reduce((s,u)=>{const n=et[u];return!n||!e.some(f=>f.code===n)?s:{...s,[n]:t[u]}},{}),[e,t])}const rt=({addressType:e,customer:t})=>e===R.BILLING?t.defaultBillingAddress:t.defaultShippingAddress,nt=({addressType:e,cart:t})=>{if(e===R.BILLING)return t.billingAddress;const r=t.shippingAddresses;if(!(!r||r.length===0))return r[0]},ot=({billingAddress:e,billToShippingAddress:t,login:r,paymentMethods:o,placeOrder:s,shippingAddress:u,shippingMethods:n})=>O(ae,{children:[a(_,{node:r}),u&&a(_,{node:u}),t&&a(_,{node:t}),n&&a(_,{node:n}),a(_,{node:o}),a(_,{node:e}),a(_,{node:s})]}),at=({sections:e})=>O("div",{className:"checkout__content",children:[a(ce,{level:1,className:"checkout-title",children:a(ne,{id:"Checkout.title"})}),e&&a(ot,{...e})]}),st=({children:e,className:t,isLoading:r=!1,...o})=>O("div",{"data-testid":"checkout",className:B(["checkout",t]),...o,children:[r&&a(ct,{}),a(Le,{}),a(ye,{}),e]});st.Main=at;const ce=({className:e,children:t,level:r=2})=>{const o=r>=1&&r<=6?`h${r}`:"h2";return a(o,{className:e,children:t})},it=()=>{const e=V(()=>{document.body.style.overflow="hidden"},[]),t=V(()=>{document.body.style.overflow=""},[]);return{lockScroll:e,unlockScroll:t}},ct=({className:e})=>{const{lockScroll:t,unlockScroll:r}=it();return z(()=>(t(),r),[t,r]),a("div",{"data-testid":"checkout-overlay-loader",className:B(["checkout-overlay-loader",e]),children:a(ke,{})})};export{St as A,st as C,ce as H,x as p};
|
|
1
|
+
import{events as re}from"@dropins/tools/event-bus.js";import{A as P,z as L,n as ne,V as w,B as ge,q as fe,m as he}from"./fixtures.js";import{b as Y,a as F,A as R,e as pe,D as U,g as Fe,M as Q,c as ee}from"./getMultilineValues.js";import{useState as q,useCallback as O,useEffect as z,useRef as ve,useMemo as Ie}from"@dropins/tools/preact-hooks.js";import{classes as V,getFormErrors as Ee,VComponent as _}from"@dropins/tools/lib.js";import{Text as oe,useText as Ae}from"@dropins/tools/i18n.js";import{Field as Z,Input as ae,Picker as Ce,Skeleton as Se,SkeletonRow as k,ProgressSpinner as ke}from"@dropins/tools/components.js";/* empty css */import{jsx as s,Fragment as se,jsxs as B}from"@dropins/tools/preact-jsx-runtime.js";import{forwardRef as be,useRef as Me,useImperativeHandle as $e,useState as j,useEffect as W}from"@dropins/tools/preact-compat.js";import{u as Re}from"./address-form-fields.js";import{E as Le}from"./ErrorBanner.js";import{M as we}from"./MergedCartBanner.js";const X={firstname:"given-name",lastname:"family-name",company:"organization",country:"country",region:"address-level1",city:"address-level2",postcode:"postal-code",telephone:"tel",street:"address-line1",email:"email",middlename:"additional-name",prefix:"honorific-prefix",suffix:"honorific-suffix"};function ie(e){return Object.keys(e).length===0&&e.constructor===Object}const ye=e=>e.map(t=>{var n;const r=((n=t==null?void 0:t.id)==null?void 0:n.toString())||t.code;return{text:t.name,value:r}}),Ne=e=>e?e.map(t=>({text:t.label,value:t.value})):[];function De({address:e,addressType:t,availableCountries:r,availableRegions:n,config:a,dismissError:i,errors:o,fields:d,onBlur:g,onChange:v,onInvalid:c,onSelection:h,setAddress:E}){const p=()=>{E(l=>({...l,[F.Region]:"",[F.RegionId]:""})),i(F.Region)},A=l=>{E(S=>({...S,[F.RegionId]:l}))};return d.map(l=>{var I;let S,m=l.frontendInput,C=h,y=v,N=l.isDisabled,D=l.isRequired,b=[],u;return m===P.Multiline?(u=Y(l.code,e),S=Y(l.code,o)):(u=e[l.code],S=o[l.code]||""),l.code===F.Country&&(b=Ne(r),t===R.SHIPPING&&(L.value.country=u,C=f=>{const M=f.target,{value:$}=M;$&&H({country_code:$}),h(f),p()})),l.code===F.RegionId&&t===R.SHIPPING&&(L.value.selectedRegionId=u),l.code===F.Region&&(t===L.value.addressType&&(N=L.value.pending),D=a.countriesWithRequiredRegion.includes(e==null?void 0:e.country_id),b=ye(n),!D&&!a.displayStateIfOptional&&(m=P.Undefined),m=b.length>0?P.Select:P.Text,m===P.Select?t===R.SHIPPING?(L.value.selectedRegion=u,C=f=>{const $=f.target.value;H({country_code:L.value.country,region_id:$}),h(f),A($)}):C=f=>{h(f);const $=f.target.value;A($)}:m===P.Text&&t===R.SHIPPING&&(L.value.selectedRegion=u,y=f=>{const M=f.target,{value:$}=M;L.value.country&&H({country_code:L.value.country,region_name:$}),v(f)}),u=b.length>0?((I=b.find(f=>f.value===u))==null?void 0:I.value)||"":u),l.code===F.PostCode&&(D=!a.countriesWithOptionalZipCode.includes(e==null?void 0:e.country_id)),{...l,error:S,frontendInput:m,handleSelect:C,isDisabled:N,isRequired:D,onBlur:g,onChange:y,onInvalid:c,options:b,value:u}})}let te;function H(e){var i;const t=ne.value.data,r=!!t,n=(i=t==null?void 0:t.shippingAddresses)==null?void 0:i[0],a=n==null?void 0:n.availableShippingMethods;r&&!a&&(clearTimeout(te),te=setTimeout(()=>{pe({criteria:e})},U))}const G=({addressType:e,code:t,index:r})=>r?`${e}-${t}-${r}`:`${e}-${t}`,T=e=>`checkout-address-form__${e}`,_e=({addressType:e,element:t})=>{const{code:r,value:n,defaultValue:a}=t;return s("input",{className:T(r),id:G({addressType:e,code:r}),name:r,type:"hidden",value:n||a},r)},xe=({addressType:e,element:t})=>{const{code:r,error:n,isDisabled:a,label:i,onBlur:o,onChange:d,onInvalid:g,validateRules:v,value:c}=t,h=ce(v);return s(Z,{disabled:a,error:n,children:s(ae,{"aria-label":i,autocomplete:X[r]||"off",className:T(r),floatingLabel:`${i} ${t.isRequired?"*":""}`,id:G({addressType:e,code:r}),onBlur:o,onChange:d,onInvalid:g,placeholder:i,required:t.isRequired||!1,type:"text",name:r,value:c??void 0,...h})})},ze=({addressType:e,element:t})=>{const{code:r,error:n,isDisabled:a,isRequired:i,label:o,multilineCount:d,onBlur:g,onChange:v,onInvalid:c,validateRules:h,value:E}=t,p=d??0,A=ce(h);return s(se,{children:Array.from(Array(p).keys()).map(l=>s(Z,{disabled:a,error:(n==null?void 0:n[l])||"",className:"dropin-field--multiline",children:s(ae,{id:G({addressType:e,code:r,index:l}),className:T(r),floatingLabel:`${o} ${l!=0?l:""} ${i&&l===0?"*":""}`,autocomplete:l===0?X[r]:"off","aria-label":o,placeholder:`${o} ${l!=0?l:""}`,type:"text",required:i&&l===0,onChange:v,onBlur:g,onInvalid:c,name:`${r}-${l}`,value:(E==null?void 0:E[l])||void 0,...A})},`${r}-${l}`))})},Pe=({addressType:e,element:t})=>{const{code:r,error:n,handleSelect:a,isDisabled:i,isRequired:o,label:d,onBlur:g,onInvalid:v,options:c,value:h}=t,E=a?{handleSelect:a}:{};return s(Z,{disabled:i,error:n,children:s(Ce,{id:G({addressType:e,code:r}),className:T(r),name:r,floatingLabel:`${d} ${o?"*":""}`,required:o,placeholder:d,"aria-label":d,options:c,value:h,autocomplete:X[r]||"off",onBlur:g,onInvalid:v,...E},r)})},Oe=({addressType:e,element:t})=>{switch(t.frontendInput){case"BOOLEAN":case"DATE":case"DATETIME":case"FILE":case"GALLERY":case"IMAGE":case"MEDIA_IMAGE":case"MULTISELECT":case"PRICE":case"TEXTAREA":case"UNDEFINED":case"WEIGHT":return null;case"HIDDEN":return _e({addressType:e,element:t});case"TEXT":return xe({addressType:e,element:t});case"MULTILINE":return ze({addressType:e,element:t});case"SELECT":return Pe({addressType:e,element:t});default:return null}},ce=e=>e?e.reduce((t,r)=>{switch(r.name){case w.DateRangeMax:return{...t,max:r.value};case w.DateRangeMin:return{...t,min:r.value};case w.FileExtensions:return{...t,accept:r.value};case w.InputValidation:return{...t,pattern:Be(r.value)};case w.MaxFileSize:case w.MaxImageHeight:case w.MaxImageWidth:return t;case w.MaxTextLength:return{...t,maxLength:r.value};case w.MinTextLength:return{...t,minLength:r.value};default:throw new Error(`Unknown rule: ${r.name}`)}},{}):{},x={alpha:/^[a-zA-Z]+$/,alphanumeric:/^[a-zA-Z0-9]+$/,"alphanumeric-w-space":/^[a-zA-Z0-9 ]+$/,"alphanum-with-spaces":/^[a-zA-Z0-9 ]+$/,email:/^([a-z0-9,!#$%&'*+/=?^_`{|}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!#$%&'*+/=?^_`{|}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i,numeric:/^[0-9]+$/,url:/^((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w\-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\\w]*))?)$/},Be=e=>{switch(e){case"alpha":return x.alpha.source;case"alphanumeric":return x.alphanumeric.source;case"alphanumeric-w-space":return x["alphanumeric-w-space"].source;case"alphanum-with-spaces":return x["alphanum-with-spaces"].source;case"url":return x.url.source;case"numeric":return x.numeric.source;case"email":return x.email.source;default:throw new Error(`Unknown validation type: ${e}`)}},Ve=e=>B(Se,{...e,children:[s(k,{variant:"heading",size:"medium"}),s(k,{variant:"empty",size:"medium"}),s(k,{size:"large"}),s(k,{size:"large"}),s(k,{size:"large",fullWidth:!0}),s(k,{size:"large",fullWidth:!0,lines:3}),s(k,{size:"large"}),s(k,{size:"large"}),s(k,{size:"large"}),s(k,{size:"large"}),s(k,{size:"large"}),s(k,{size:"large"}),s(k,{size:"large"})]}),Ue=({addressType:e,className:t,fields:r,formRef:n,headingId:a,name:i,...o})=>B("div",{...o,className:V(["checkout-fields-form",t]),children:[s(le,{level:2,children:s(oe,{id:a}),className:"checkout-fields-form__title"}),s("form",{name:i,ref:n,className:V(["checkout-fields-form__form",t]),noValidate:!0,children:r.sort((d,g)=>!d.sortOrder||!g.sortOrder?d.code<g.code?-1:1:d.sortOrder-g.sortOrder).map(d=>Oe({element:d,addressType:e}))})]}),Ge=e=>{const t=new FormData(e),r=Object.fromEntries(t);return Object.entries(r).reduce((a,[i])=>{const o=e.elements[i];return o!=null&&o.validationMessage?{...a,[i]:o.validationMessage}:{...a}},{})};function Te(e){const[t,r]=j({});return W(()=>{e&&r(n=>({...n,country_id:e}))},[e]),{defaultValues:t}}function He({country:e,addressType:t}){const[r,n]=j([]);return W(()=>{if(!e){n([]);return}Fe(e,t).then(a=>{n(a||[])}).catch(a=>{console.error(a)})},[n,e,t]),{availableRegions:r}}function qe({autoFill:e,addressType:t,dismissError:r,loadAutoFill:n}){const[a,i]=j(!1),o=he.value.data,d=!!o,g=ne.value.data,v=!!g;W(()=>{var S;if(!e||!v||a)return;let c,h=!1;c=it({addressType:t,cart:g}),!c&&d&&(c=st({addressType:t,customer:o}),h=!0);const E=m=>m?m.split(ee).length>1:!1;if(!c)return;i(!0);const p={[F.City]:c.city,[F.Company]:c.company||"",[F.Country]:c.country.value,[F.FirstName]:c.firstName,[F.LastName]:c.lastName,[F.PostCode]:c.postCode||"",[F.Telephone]:c.telephone||"",[F.Vat]:c.vatId||""},A=c.region;if(A){const m=(S=A==null?void 0:A.id)==null?void 0:S.toString();m?(p[F.Region]=m,p[F.RegionId]=m):p[F.Region]=A.code}c!=null&&c.street&&c.street.length>0&&c.street.forEach((m,C)=>{p[`${F.Street}${Q}${C}`]=m}),((c==null?void 0:c.customAttributes)||[]).forEach(m=>{E(m.code)?m.value.split(ee).forEach((y,N)=>{p[`${m.code}${Q}${N}`]=y}):p[m.code]=m.value}),n({values:p,triggerAutoSave:h})},[t,e,g,o,a,v,d,n,r])}const $t=be(({addressType:e,autoFill:t=!0,children:r,headingId:n,name:a,preselectedFields:i,saveAddressHandler:o,...d},g)=>{const{fields:v}=Re(),c=ge.value.data,h=c===void 0,E=v===void 0,p=fe.value.data,A=p===void 0,{defaultValues:l}=Te(p==null?void 0:p.defaultCountry),S=at({fields:v,preselectedFields:i}),m=Me(null),{address:C,errors:y,loadAutoFill:N,onBlur:D,dismissError:b,onChange:u,onInvalid:I,onSelection:f,setAddress:M}=nt({formRef:m,type:e,defaultValues:l,preselection:S,saveAddressHandler:o}),{availableRegions:$}=He({country:C.country_id,addressType:e});if($e(g,()=>({triggerSaveAddress:de=>{if(!m.current)return;const me=Ge(m.current);if(ie(me))return o({signal:de,address:C})}})),qe({addressType:e,autoFill:t,loadAutoFill:N,dismissError:b}),E||h||A)return s(Ve,{"data-testid":`${e}-skeleton`});const ue=De({address:C,addressType:e,availableCountries:c,availableRegions:$,config:p,dismissError:b,errors:y,fields:v,onBlur:D,onChange:u,onInvalid:I,onSelection:f,setAddress:M}),K={[R.SHIPPING]:"shipping",[R.BILLING]:"billing"};return s(Ue,{...d,name:a,addressType:e,className:`checkout-${K[e]}-form`,"data-testid":`${K[e]}-form`,fields:ue,formRef:m,headingId:n})}),Ze="DROPIN__CHECKOUT",J=e=>`${Ze}__${e.toUpperCase()}`,je=(e,t)=>{window.localStorage.setItem(J(e),JSON.stringify(t))},We=e=>{const t=window.localStorage.getItem(J(e));return t?JSON.parse(t):null},Xe=e=>{window.localStorage.removeItem(J(e))};function Je(e){const[t,r]=q(null),n=O(i=>setTimeout(()=>{je(e,i)},U),[e]),a=O(()=>{Xe(e)},[e]);return z(()=>{const i=We(e);i&&r(i)},[e]),z(()=>{const i=re.on("checkout/order",()=>{a()});return()=>{i==null||i.off()}},[a]),{addressBackup:t,backupAddress:n,removeAddressBackup:a}}const Ke={[R.BILLING]:"billing",[R.SHIPPING]:"shipping"};function Ye({address:e,type:t}){z(()=>{const r=setTimeout(()=>{re.emit("checkout/address",{type:Ke[t],address:e})},U);return()=>{clearTimeout(r)}},[e,t])}const Qe={badInput:"aria-label",patternMismatch:"aria-label",rangeOverflow:"max",rangeUnderflow:"min",tooLong:"maxlength",tooShort:"minlength",typeMismatch:"aria-label",valueMissing:"aria-label"},et=["badInput","patternMismatch","rangeOverflow","rangeUnderflow","tooLong","tooShort","typeMismatch","valueMissing"],tt=e=>{const[t,r]=q({}),n=O(o=>{const{name:d,validity:g,validationMessage:v}=o;let c=g.valid?"":v;et.forEach(h=>{if(!g[h])return;const E=e[h];if(!E)return;const p=Qe[h];c=E.replace("{field}",o.getAttribute(p)||"")}),r(h=>({...h,[d]:c}))},[e]);return{errors:t,dismissError:o=>{t[o]&&r(d=>{const{[o]:g,...v}=d;return v})},validateFormElement:n,resetErrors:()=>{r({})}}},rt=e=>{const t=e.current;if(!t)return!1;const r=Ee(t);return ie(r)},nt=({formRef:e,type:t,defaultValues:r={},preselection:n={},saveAddressHandler:a})=>{const i=Ae({badInput:"Checkout.AddressForm.Validity.badInput",patternMismatch:"Checkout.AddressForm.Validity.patternMismatch",rangeUnderflow:"Checkout.AddressForm.Validity.rangeUnderflow",tooLong:"Checkout.AddressForm.Validity.tooLong",tooShort:"Checkout.AddressForm.Validity.tooShort",typeMismatch:"Checkout.AddressForm.Validity.typeMismatch",valueMissing:"Checkout.AddressForm.Validity.valueMissing"}),o=ve(!1),[d,g]=q({});Ye({address:d,type:t});const{addressBackup:v,backupAddress:c,removeAddressBackup:h}=Je(t),{errors:E,validateFormElement:p,dismissError:A,resetErrors:l}=tt(i),S=O(u=>{o.current=!1,a(u).then(()=>{h()}).catch(I=>{o.current=!0,console.error("Saving address form failed:",I)})},[h,a]),m=(u,I)=>{g(f=>({...f,[u]:I})),o.current=!0},C=({values:u,triggerAutoSave:I=!1})=>{l(),g(f=>({...f,...u})),I&&(o.current=!0)},y=u=>{const I=u.target,{name:f,value:M}=I;m(f,M),p(I)},N=u=>{const I=u.target;p(I)},D=u=>{const I=u.target,{name:f,value:M}=I;m(f,M),p(I)},b=u=>{u.target.checkValidity()};return z(()=>{g(u=>({...r,...n,...v,...u}))},[r,n,v]),z(()=>{if(!o.current)return;const u=c(d);return()=>{clearTimeout(u)}},[d,c]),z(()=>{if(!o.current||!rt(e))return;const u=new AbortController,I=u.signal,f=setTimeout(()=>{S({signal:I,address:d})},U);return()=>{clearTimeout(f),u.abort()}},[d,e,S]),{address:d,errors:E,loadAutoFill:C,dismissError:A,onChange:y,onSelection:D,onBlur:b,onInvalid:N,setAddress:g}},ot={countryCode:F.Country,region:F.Region,postCode:F.PostCode};function at({fields:e,preselectedFields:t}){return Ie(()=>!(!!e&&e.length>0)||!!!t?{}:Object.keys(t).reduce((a,i)=>{const o=ot[i];return!o||!e.some(g=>g.code===o)?a:{...a,[o]:t[i]}},{}),[e,t])}const st=({addressType:e,customer:t})=>e===R.BILLING?t.defaultBillingAddress:t.defaultShippingAddress,it=({addressType:e,cart:t})=>{if(e===R.BILLING)return t.billingAddress;const r=t.shippingAddresses;if(!(!r||r.length===0))return r[0]},ct=({billingAddress:e,billToShippingAddress:t,login:r,paymentMethods:n,placeOrder:a,shippingAddress:i,shippingMethods:o})=>B(se,{children:[s(_,{node:r}),i&&s(_,{node:i}),t&&s(_,{node:t}),o&&s(_,{node:o}),s(_,{node:n}),s(_,{node:e}),s(_,{node:a})]}),lt=({sections:e})=>B("div",{className:"checkout__content",children:[s(le,{level:1,className:"checkout-title",children:s(oe,{id:"Checkout.title"})}),e&&s(ct,{...e})]}),ut=({children:e,className:t,isLoading:r=!1,...n})=>B("div",{"data-testid":"checkout",className:V(["checkout",t]),...n,children:[r&&s(mt,{}),s(Le,{}),s(we,{}),e]});ut.Main=lt;const le=({className:e,children:t,level:r=2})=>{const n=r>=1&&r<=6?`h${r}`:"h2";return s(n,{className:e,children:t})},dt=()=>{const e=O(()=>{document.body.style.overflow="hidden"},[]),t=O(()=>{document.body.style.overflow=""},[]);return{lockScroll:e,unlockScroll:t}},mt=({className:e})=>{const{lockScroll:t,unlockScroll:r}=dt();return z(()=>(t(),r),[t,r]),s("div",{"data-testid":"checkout-overlay-loader",className:V(["checkout-overlay-loader",e]),children:s(ke,{})})};export{$t as A,ut as C,le as H,x as p};
|
package/chunks/ToggleButton2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@dropins/tools/event-bus.js";import{
|
|
1
|
+
import"@dropins/tools/event-bus.js";import{n as L}from"./fixtures.js";import{s as z}from"./setPaymentMethod.js";import{H as O}from"./ToggleButton.js";import"@dropins/tools/preact-hooks.js";import{classes as f,Slot as E}from"@dropins/tools/lib.js";import{Skeleton as U,SkeletonRow as v,IllustratedMessage as $,Icon as q,ProgressSpinner as Z,Divider as F,RadioButton as G}from"@dropins/tools/components.js";/* empty css */import{jsxs as y,jsx as e,Fragment as J}from"@dropins/tools/preact-jsx-runtime.js";import*as M from"@dropins/tools/preact-compat.js";import{useState as P,useCallback as x,useEffect as N}from"@dropins/tools/preact-compat.js";import{useText as K}from"@dropins/tools/i18n.js";const Q=t=>M.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},M.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"}),M.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),M.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),X=()=>y(U,{"data-testid":"payment-methods-skeleton",children:[e(v,{variant:"heading",size:"medium"}),e(v,{variant:"empty",size:"medium"}),e(v,{size:"xlarge",fullWidth:!0}),e(v,{size:"xlarge",fullWidth:!0})]}),Y=({code:t,isLoading:n,isSelected:d,onChange:s,title:o})=>e(te,{className:"checkout-payment-methods__method",label:o,name:"payment-method",value:t,selected:d,onChange:s,radioButtonProps:{"aria-busy":n}}),D=({className:t,paymentMethodContent:n,isLoading:d,onChange:s=()=>{},options:o,selection:u})=>{const l=K({Title:"Checkout.PaymentMethods.title",EmptyState:"Checkout.PaymentMethods.emptyState"});return o===void 0?e(X,{}):y("div",{className:f(["checkout-payment-methods",t]),children:[e(O,{level:2,className:"checkout-payment-methods__title",children:l.Title}),!d&&o.length===0&&e($,{icon:e(q,{source:Q}),message:e("p",{children:l.EmptyState})}),y("div",{className:f(["checkout-payment-methods__wrapper"]),children:[d&&e(Z,{className:"checkout-payment-methods__spinner"}),e("div",{className:f(["checkout-payment-methods__methods",["checkout-payment-methods--loading",d],["checkout-payment-methods--full-width",o.length%2!==0]]),children:o==null?void 0:o.map(m=>e(Y,{code:m.code,onChange:s,isSelected:m.code===u,title:m.title},m.code))}),n&&e("div",{className:"checkout-payment-methods__content",children:n})]}),e(F,{variant:"primary"})]})},T={free:{render:t=>{const n=document.createElement("div");n.innerText="",t.replaceHTML(n)}},checkmo:{render:t=>{const n=document.createElement("div");n.innerText="",t.replaceHTML(n)}}};function ee(t){var w;const{onPlaceOrder:n,handleServerError:d,paymentMethodsSlot:s,isShippingInfoRequired:o}=t,[u,l]=P(),[m,g]=P(),[h,_]=P(T),[C,I]=P(!0),{data:a}=L.value,W=(a==null?void 0:a.id)??"",H=!!a,b=!!((w=a==null?void 0:a.shippingAddresses)!=null&&w[0]),i=a==null?void 0:a.availablePaymentMethods,c=a==null?void 0:a.selectedPaymentMethod,k=x(async r=>{try{if(l(r),!b&&o||r===(c==null?void 0:c.code))return;await z(r)}catch(p){console.error("setting payment method failed:",p)}},[b,o,c]);N(()=>{H&&(c!=null&&c.code?(i==null?void 0:i.some(p=>p.code===c.code))?l(c.code):i!=null&&i.length?k(i[0].code):l(void 0):i[0]&&k(m||i[0].code))},[i,H,c,k,m]);const B=async r=>{await k(r),c!=null&&c.code||g(r)},V=x((r,p)=>{if(!r){console.warn("Payment method handler is ignored because it has no code");return}if(!p){console.warn("Payment method handler is ignored because it is empty");return}_(R=>({...R,[r]:p}))},[]),j=s?e(E,{name:"PaymentMethods",slot:s,context:{addPaymentMethodHandler:V,replaceHTML(r){this.replaceWith(r),I(!1)}}}):null,S=u?h[u]:null,A=S?e(E,{name:"PaymentMethodContent",slot:S.render,context:{cartId:W,onPlaceOrder:n,handleServerError:d,replaceHTML(r){this.replaceWith(r)}}},S):void 0;return N(()=>{!C&&h!=T&&console.warn("Payment method handlers you have added are ignored because the default content has been replaced")},[C,h]),{availablePaymentMethods:i,selectedPaymentMethod:u,onPaymentMethodChange:B,paymentMethodContent:A,mainSlotContent:j,isDefaultContentUsed:C}}const ue=t=>{const{onPlaceOrder:n,handleServerError:d,paymentMethodsSlot:s,isShippingInfoRequired:o=!0}=t,{availablePaymentMethods:u,selectedPaymentMethod:l,onPaymentMethodChange:m,paymentMethodContent:g,mainSlotContent:h,isDefaultContentUsed:_}=ee({onPlaceOrder:n,handleServerError:d,paymentMethodsSlot:s,isShippingInfoRequired:o});return y(J,{children:[h&&e(h.type,{ref:h.ref,...h.props}),_&&e(D,{options:u,selection:l,onChange:m,paymentMethodContent:g,isLoading:L.value.pending})]})},te=({label:t,name:n,value:d,icon:s,selected:o,onChange:u,className:l,children:m,radioButtonProps:g,...h})=>e("div",{className:f(["checkout-toggle-button",l,["checkout-toggle-button__selected",o]]),...h,children:y("label",{className:"checkout-toggle-button__actionButton",children:[e(G,{...g,label:"",name:n,value:d,checked:o,onChange:()=>u(d),"aria-label":t,className:f([l,"checkout-toggle-button__radioButton"])}),y("div",{className:"checkout-toggle-button__content",children:[s&&e(s.type,{...s==null?void 0:s.props,className:"checkout-toggle-button__icon"}),t]})]})});export{ue as P};
|
|
@@ -1,43 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
mutation estimateShippingMethods(
|
|
3
|
-
$cartId: String!
|
|
4
|
-
$address: EstimateAddressInput!
|
|
5
|
-
) {
|
|
6
|
-
estimateShippingMethods(
|
|
7
|
-
input: {
|
|
8
|
-
cart_id: $cartId
|
|
9
|
-
address: $address
|
|
10
|
-
}
|
|
11
|
-
) {
|
|
12
|
-
carrier_title
|
|
13
|
-
carrier_code
|
|
14
|
-
method_title
|
|
15
|
-
method_code
|
|
16
|
-
available
|
|
17
|
-
amount {
|
|
18
|
-
currency
|
|
19
|
-
value
|
|
20
|
-
}
|
|
21
|
-
price_excl_tax {
|
|
22
|
-
currency
|
|
23
|
-
value
|
|
24
|
-
}
|
|
25
|
-
price_incl_tax {
|
|
26
|
-
currency
|
|
27
|
-
value
|
|
28
|
-
}
|
|
29
|
-
error_message
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
`,M=t=>t?!!t.id&&!!t.code&&!!t.name:!1,S=t=>{if(t)return t.filter(M).map(e=>{const{id:a,code:n,name:i}=e;return{id:a,code:n,name:i}})},L=async t=>{const e=_.cartId,{criteria:a}=t||{},{country_code:n,region_id:i,region_name:s,zip:r}=a||{};if(!e)throw new y;if(!n)throw new h;const o=typeof i=="string"?parseInt(i,10):i,c=i||s?{...o&&{region_id:o},...s&&{region_code:s}}:void 0,u={country_code:n,...r&&{postcode:r},...c&&{region:c}};return await g({type:"mutation",query:I,options:{variables:{cartId:e,address:u}},path:"estimateShippingMethods",signalType:"estimateShippingMethods",transformer:m})},f=`
|
|
33
|
-
query getRegions($countryCode: String!) {
|
|
34
|
-
country(id: $countryCode) {
|
|
35
|
-
id
|
|
36
|
-
available_regions {
|
|
37
|
-
id
|
|
38
|
-
code
|
|
39
|
-
name
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}`,N=async(t,e)=>(l.value.addressType=e,g({type:"query",query:f,options:{variables:{countryCode:t}},path:"country.available_regions",signalType:"regions",transformer:S})),p="-",R=`
|
|
43
|
-
`,E=2e3,w=(t,e)=>Object.keys(e).filter(a=>a.startsWith(t)).sort((a,n)=>parseInt(a.replace(`${t}${p}`,""),10)-parseInt(n.replace(`${t}${p}`,""),10)).map(a=>e[a]);var v=(t=>(t.SHIPPING="shipping_addresses",t.BILLING="billing_address",t))(v||{}),d=(t=>(t.City="city",t.Company="company",t.Country="country_id",t.FirstName="firstname",t.LastName="lastname",t.PostCode="postcode",t.Region="region",t.RegionId="region_id",t.SaveInAddressBook="save_in_address_book",t.Street="street",t.Telephone="telephone",t.Vat="vat_id",t))(d||{});export{v as A,E as D,p as M,d as a,w as b,R as c,L as e,N as g};
|
|
1
|
+
import"@dropins/tools/event-bus.js";import{i as d}from"./fixtures.js";import{createContext as i}from"@dropins/tools/preact.js";import{useContext as n,useState as m,useEffect as u}from"@dropins/tools/preact-hooks.js";import{jsx as F}from"@dropins/tools/preact-jsx-runtime.js";const r=i(void 0);function p({children:e}){const[s,t]=m({});return u(()=>{d().then(o=>t({fields:o}))},[]),F(r.Provider,{value:s,children:e})}function v(){const e=n(r);if(e!==void 0)return e;throw new Error("useAddressFormFields must be used within an AddressFormFieldsProvider")}export{p as A,v as u};
|
package/chunks/fixtures.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import{events as Q}from"@dropins/tools/event-bus.js";import{Component as j,options as q,isValidElement as W}from"@dropins/tools/preact.js";import{useMemo as G}from"@dropins/tools/preact-hooks.js";import{FetchGraphQL as V}from"@dropins/tools/fetch-graphql.js";class Z extends Error{constructor(t){super(t.map(i=>i.message).join(" ")),this.name="FetchError"}}class S extends Error{constructor(t){super(t),this.name="InvalidArgument"}}class be extends Error{constructor(t){super(t),this.name="UnexpectedError"}}class Ee extends S{constructor(){super("Cart ID is required")}}class Te extends S{constructor(){super("Email is required")}}class Me extends S{constructor(){super("Payment method code is required")}}class we extends S{constructor(){super("Billing address is required")}}class Ie extends S{constructor(){super("Country Code is required")}}const I=e=>{throw e instanceof DOMException&&e.name==="AbortError"||Q.emit("error",{source:"checkout",type:"network",error:e}),e};var z=Symbol.for("preact-signals");function C(){if(p>1)p--;else{for(var e,t=!1;m!==void 0;){var i=m;for(m=void 0,D++;i!==void 0;){var r=i.o;if(i.o=void 0,i.f&=-3,!(8&i.f)&&L(i))try{i.c()}catch(n){t||(e=n,t=!0)}i=r}}if(D=0,p--,t)throw e}}var o=void 0,m=void 0,p=0,D=0,E=0;function $(e){if(o!==void 0){var t=e.n;if(t===void 0||t.t!==o)return t={i:0,S:e,p:o.s,n:void 0,t:o,e:void 0,x:void 0,r:t},o.s!==void 0&&(o.s.n=t),o.s=t,e.n=t,32&o.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=o.s,t.n=void 0,o.s.n=t,o.s=t),t}}function f(e){this.v=e,this.i=0,this.n=void 0,this.t=void 0}f.prototype.brand=z;f.prototype.h=function(){return!0};f.prototype.S=function(e){this.t!==e&&e.e===void 0&&(e.x=this.t,this.t!==void 0&&(this.t.e=e),this.t=e)};f.prototype.U=function(e){if(this.t!==void 0){var t=e.e,i=e.x;t!==void 0&&(t.x=i,e.e=void 0),i!==void 0&&(i.e=t,e.x=void 0),e===this.t&&(this.t=i)}};f.prototype.subscribe=function(e){var t=this;return b(function(){var i=t.value,r=o;o=void 0;try{e(i)}finally{o=r}})};f.prototype.valueOf=function(){return this.value};f.prototype.toString=function(){return this.value+""};f.prototype.toJSON=function(){return this.value};f.prototype.peek=function(){var e=o;o=void 0;try{return this.value}finally{o=e}};Object.defineProperty(f.prototype,"value",{get:function(){var e=$(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(D>100)throw new Error("Cycle detected");this.v=e,this.i++,E++,p++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{C()}}}});function c(e){return new f(e)}function L(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function F(e){for(var t=e.s;t!==void 0;t=t.n){var i=t.S.n;if(i!==void 0&&(t.r=i),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function P(e){for(var t=e.s,i=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):i=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=i}function _(e){f.call(this,void 0),this.x=e,this.s=void 0,this.g=E-1,this.f=4}(_.prototype=new f).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===E))return!0;if(this.g=E,this.f|=1,this.i>0&&!L(this))return this.f&=-2,!0;var e=o;try{F(this),o=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(i){this.v=i,this.f|=16,this.i++}return o=e,P(this),this.f&=-2,!0};_.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}f.prototype.S.call(this,e)};_.prototype.U=function(e){if(this.t!==void 0&&(f.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};_.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(_.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=$(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function J(e){return new _(e)}function H(e){var t=e.u;if(e.u=void 0,typeof t=="function"){p++;var i=o;o=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,N(e),r}finally{o=i,C()}}}function N(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,H(e)}function Y(e){if(o!==this)throw new Error("Out-of-order effect");P(this),o=e,this.f&=-2,8&this.f&&N(this),C()}function x(e){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}x.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}};x.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,H(this),F(this),p++;var e=o;return o=this,Y.bind(this,e)};x.prototype.N=function(){2&this.f||(this.f|=2,this.o=m,m=this)};x.prototype.d=function(){this.f|=8,1&this.f||N(this)};function b(e){var t=new x(e);try{t.c()}catch(i){throw t.d(),i}return t.d.bind(t)}var M;function g(e,t){q[e]=t.bind(null,q[e]||function(){})}function T(e){M&&M(),M=e&&e.S()}function k(e){var t=this,i=e.data,r=ee(i);r.value=i;var n=G(function(){for(var s=t.__v;s=s.__;)if(s.__c){s.__c.__$f|=4;break}return t.__$u.c=function(){var a;!W(n.peek())&&((a=t.base)==null?void 0:a.nodeType)===3?t.base.data=n.peek():(t.__$f|=1,t.setState({}))},J(function(){var a=r.value.value;return a===0?0:a===!0?"":a||""})},[]);return n.value}k.displayName="_st";Object.defineProperties(f.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:k},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});g("__b",function(e,t){if(typeof t.type=="string"){var i,r=t.props;for(var n in r)if(n!=="children"){var s=r[n];s instanceof f&&(i||(t.__np=i={}),i[n]=s,r[n]=s.peek())}}e(t)});g("__r",function(e,t){T();var i,r=t.__c;r&&(r.__$f&=-2,(i=r.__$u)===void 0&&(r.__$u=i=function(n){var s;return b(function(){s=this}),s.c=function(){r.__$f|=1,r.setState({})},s}())),T(i),e(t)});g("__e",function(e,t,i,r){T(),e(t,i,r)});g("diffed",function(e,t){T();var i;if(typeof t.type=="string"&&(i=t.__e)){var r=t.__np,n=t.props;if(r){var s=i.U;if(s)for(var a in s){var u=s[a];u!==void 0&&!(a in r)&&(u.d(),s[a]=void 0)}else i.U=s={};for(var l in r){var v=s[l],h=r[l];v===void 0?(v=K(i,l,h,n),s[l]=v):v.o(h,n)}}}e(t)});function K(e,t,i,r){var n=t in e&&e.ownerSVGElement===void 0,s=c(i);return{o:function(a,u){s.value=a,r=u},d:b(function(){var a=s.value.value;r[t]!==a&&(r[t]=a,n?e[t]=a:a?e.setAttribute(t,a):e.removeAttribute(t))})}}g("unmount",function(e,t){if(typeof t.type=="string"){var i=t.__e;if(i){var r=i.U;if(r){i.U=void 0;for(var n in r){var s=r[n];s&&s.d()}}}}else{var a=t.__c;if(a){var u=a.__$u;u&&(a.__$u=void 0,u.d())}}e(t)});g("__h",function(e,t,i,r){(r<3||r===9)&&(t.__$f|=2),e(t,i,r)});j.prototype.shouldComponentUpdate=function(e,t){var i=this.__$u;if(!(i&&i.s!==void 0||4&this.__$f)||3&this.__$f)return!0;for(var r in t)return!0;for(var n in e)if(n!=="__source"&&e[n]!==this.props[n])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function ee(e){return G(function(){return c(e)},[])}const B=c({pending:!1,data:void 0}),te=c(null);b(()=>{te.value||(B.value={data:null,pending:!1})});const ie=c({checked:!0,setByUser:!1}),X=c({pending:!1,data:void 0});b(()=>{var e;(e=X.value.data)!=null&&e.isVirtual&&(ie.value={checked:!1,setByUser:!1})});const re=c({pending:!1,data:void 0}),se=c({pending:!1,data:void 0}),oe=c({data:void 0,pending:!1}),w=[];function ne(e){return new Promise((t,i)=>{w.push(e);const r=()=>{w[0]===e?e().then(t).catch(i).finally(()=>w.shift()):setTimeout(r,100)};r()})}const ae=["sender_email","recipient_email"];function fe(e){return e.filter(t=>!t.path||!ae.some(i=>{var r;return((r=t.path)==null?void 0:r.at(-1))===i}))}const le={cart:X,customer:B,estimateShippingMethods:re,regions:se,storeConfig:oe};function de(e,t){return t.split(".").reduce((i,r)=>i&&i[r]!==void 0?i[r]:void 0,e)}const U={cart:null,customer:null,estimateShippingMethods:null,regions:null,storeConfig:null};async function De(e){const{defaultValueOnFail:t,query:i,options:r,path:n,signalType:s,type:a,transformer:u}=e,l=le[s],v=Symbol();U[s]=v,l.value={...l.value,pending:!0};try{const{data:h,errors:O}=await(a==="mutation"?ne(()=>A(i,r).catch(I)):A(i,{method:"GET",cache:"no-cache",...r}).catch(I));if(O){const R=fe(O);if(R.length>0)throw new Z(R)}let y=de(h,n);if(y===void 0)throw new Error(`No data found at path: ${n}`);return u&&(y=u(y)),l.value={...l.value,data:y},setTimeout(()=>{l.value={...l.value,pending:U[s]===v?!1:l.value.pending}},0),y}catch(h){if(t)return l.value={pending:!1,data:t},t;if(h.name==="AbortError")return;throw l.value={...l.value,pending:!1},h}}const ue={cartId:null,authenticated:!1},Ae=new Proxy(ue,{set(e,t,i){return e[t]=i,!0},get(e,t){return e[t]}}),ce=e=>e?e.filter(Boolean).filter(i=>(i==null?void 0:i.label)&&(i==null?void 0:i.value)).map(i=>({text:i.label,value:i.value})):[],ve=e=>e?e.filter(Boolean).filter(t=>(t==null?void 0:t.name)&&(t==null?void 0:t.value)):[],he=e=>e?e.filter(Boolean).map(i=>({code:i.code,defaultValue:i.default_value||void 0,frontendInput:i.frontend_input||void 0,isDisabled:!1,isRequired:i.is_required,label:i.label||void 0,multilineCount:i.multiline_count||void 0,options:ce(i.options),sortOrder:i.sort_order||void 0,validateRules:ve(i.validate_rules)})):[],{setEndpoint:Ce,setFetchGraphQlHeader:Ne,removeFetchGraphQlHeader:Oe,setFetchGraphQlHeaders:Re,fetchGraphQl:A,getConfig:qe}=new V().getMethods(),pe=`
|
|
1
|
+
import{events as A}from"@dropins/tools/event-bus.js";import{Component as Z,options as X,isValidElement as z}from"@dropins/tools/preact.js";import{useMemo as F}from"@dropins/tools/preact-hooks.js";import{FetchGraphQL as Y}from"@dropins/tools/fetch-graphql.js";class J extends Error{constructor(t){super(t.map(i=>i.message).join(" ")),this.name="FetchError"}}class C extends Error{constructor(t){super(t),this.name="InvalidArgument"}}class we extends Error{constructor(t){super(t),this.name="UnexpectedError"}}class Ge extends C{constructor(){super("Cart ID is required")}}class Le extends C{constructor(){super("Email is required")}}class Re extends C{constructor(){super("Payment method code is required")}}class qe extends C{constructor(){super("Billing address is required")}}class Xe extends C{constructor(){super("Country Code is required")}}const U=e=>{throw e instanceof DOMException&&e.name==="AbortError"||A.emit("error",{source:"checkout",type:"network",error:e}),e};var K=Symbol.for("preact-signals");function G(){if(y>1)y--;else{for(var e,t=!1;T!==void 0;){var i=T;for(T=void 0,O++;i!==void 0;){var r=i.o;if(i.o=void 0,i.f&=-3,!(8&i.f)&&P(i))try{i.c()}catch(o){t||(e=o,t=!0)}i=r}}if(O=0,y--,t)throw e}}var n=void 0,T=void 0,y=0,O=0,I=0;function $(e){if(n!==void 0){var t=e.n;if(t===void 0||t.t!==n)return t={i:0,S:e,p:n.s,n:void 0,t:n,e:void 0,x:void 0,r:t},n.s!==void 0&&(n.s.n=t),n.s=t,e.n=t,32&n.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=n.s,t.n=void 0,n.s.n=t,n.s=t),t}}function l(e){this.v=e,this.i=0,this.n=void 0,this.t=void 0}l.prototype.brand=K;l.prototype.h=function(){return!0};l.prototype.S=function(e){this.t!==e&&e.e===void 0&&(e.x=this.t,this.t!==void 0&&(this.t.e=e),this.t=e)};l.prototype.U=function(e){if(this.t!==void 0){var t=e.e,i=e.x;t!==void 0&&(t.x=i,e.e=void 0),i!==void 0&&(i.e=t,e.x=void 0),e===this.t&&(this.t=i)}};l.prototype.subscribe=function(e){var t=this;return x(function(){var i=t.value,r=n;n=void 0;try{e(i)}finally{n=r}})};l.prototype.valueOf=function(){return this.value};l.prototype.toString=function(){return this.value+""};l.prototype.toJSON=function(){return this.value};l.prototype.peek=function(){var e=n;n=void 0;try{return this.value}finally{n=e}};Object.defineProperty(l.prototype,"value",{get:function(){var e=$(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(O>100)throw new Error("Cycle detected");this.v=e,this.i++,I++,y++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{G()}}}});function d(e){return new l(e)}function P(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function H(e){for(var t=e.s;t!==void 0;t=t.n){var i=t.S.n;if(i!==void 0&&(t.r=i),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function B(e){for(var t=e.s,i=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):i=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=i}function m(e){l.call(this,void 0),this.x=e,this.s=void 0,this.g=I-1,this.f=4}(m.prototype=new l).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===I))return!0;if(this.g=I,this.f|=1,this.i>0&&!P(this))return this.f&=-2,!0;var e=n;try{H(this),n=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(i){this.v=i,this.f|=16,this.i++}return n=e,B(this),this.f&=-2,!0};m.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}l.prototype.S.call(this,e)};m.prototype.U=function(e){if(this.t!==void 0&&(l.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};m.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(m.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=$(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function ee(e){return new m(e)}function W(e){var t=e.u;if(e.u=void 0,typeof t=="function"){y++;var i=n;n=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,L(e),r}finally{n=i,G()}}}function L(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,W(e)}function te(e){if(n!==this)throw new Error("Out-of-order effect");B(this),n=e,this.f&=-2,8&this.f&&L(this),G()}function b(e){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}b.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}};b.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,W(this),H(this),y++;var e=n;return n=this,te.bind(this,e)};b.prototype.N=function(){2&this.f||(this.f|=2,this.o=T,T=this)};b.prototype.d=function(){this.f|=8,1&this.f||L(this)};function x(e){var t=new b(e);try{t.c()}catch(i){throw t.d(),i}return t.d.bind(t)}var D;function S(e,t){X[e]=t.bind(null,X[e]||function(){})}function N(e){D&&D(),D=e&&e.S()}function Q(e){var t=this,i=e.data,r=re(i);r.value=i;var o=F(function(){for(var s=t.__v;s=s.__;)if(s.__c){s.__c.__$f|=4;break}return t.__$u.c=function(){var a;!z(o.peek())&&((a=t.base)==null?void 0:a.nodeType)===3?t.base.data=o.peek():(t.__$f|=1,t.setState({}))},ee(function(){var a=r.value.value;return a===0?0:a===!0?"":a||""})},[]);return o.value}Q.displayName="_st";Object.defineProperties(l.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Q},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});S("__b",function(e,t){if(typeof t.type=="string"){var i,r=t.props;for(var o in r)if(o!=="children"){var s=r[o];s instanceof l&&(i||(t.__np=i={}),i[o]=s,r[o]=s.peek())}}e(t)});S("__r",function(e,t){N();var i,r=t.__c;r&&(r.__$f&=-2,(i=r.__$u)===void 0&&(r.__$u=i=function(o){var s;return x(function(){s=this}),s.c=function(){r.__$f|=1,r.setState({})},s}())),N(i),e(t)});S("__e",function(e,t,i,r){N(),e(t,i,r)});S("diffed",function(e,t){N();var i;if(typeof t.type=="string"&&(i=t.__e)){var r=t.__np,o=t.props;if(r){var s=i.U;if(s)for(var a in s){var f=s[a];f!==void 0&&!(a in r)&&(f.d(),s[a]=void 0)}else i.U=s={};for(var u in r){var v=s[u],p=r[u];v===void 0?(v=ie(i,u,p,o),s[u]=v):v.o(p,o)}}}e(t)});function ie(e,t,i,r){var o=t in e&&e.ownerSVGElement===void 0,s=d(i);return{o:function(a,f){s.value=a,r=f},d:x(function(){var a=s.value.value;r[t]!==a&&(r[t]=a,o?e[t]=a:a?e.setAttribute(t,a):e.removeAttribute(t))})}}S("unmount",function(e,t){if(typeof t.type=="string"){var i=t.__e;if(i){var r=i.U;if(r){i.U=void 0;for(var o in r){var s=r[o];s&&s.d()}}}}else{var a=t.__c;if(a){var f=a.__$u;f&&(a.__$u=void 0,f.d())}}e(t)});S("__h",function(e,t,i,r){(r<3||r===9)&&(t.__$f|=2),e(t,i,r)});Z.prototype.shouldComponentUpdate=function(e,t){var i=this.__$u;if(!(i&&i.s!==void 0||4&this.__$f)||3&this.__$f)return!0;for(var r in t)return!0;for(var o in e)if(o!=="__source"&&e[o]!==this.props[o])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function re(e){return F(function(){return d(e)},[])}const se=d({checked:!0,setByUser:!1}),_=d({pending:!1,data:void 0});x(()=>{var e;(e=_.value.data)!=null&&e.isVirtual&&(se.value={checked:!1,setByUser:!1})});x(()=>{_.value.pending||(A.emit("checkout/data",_.value.data||null),_.value.data&&A.emit("cart/updated",_.value.data.id))});const oe=d({data:void 0,pending:!1}),ne=d({pending:!1,data:void 0}),ae=d({pending:!1,data:void 0}),le=d({pending:!1,data:void 0}),ue=d({data:void 0,pending:!1}),M=[];function fe(e){return new Promise((t,i)=>{M.push(e);const r=()=>{M[0]===e?e().then(t).catch(i).finally(()=>M.shift()):setTimeout(r,100)};r()})}const ce=["sender_email","recipient_email"];function de(e){return e.filter(t=>!t.path||!ce.some(i=>{var r;return((r=t.path)==null?void 0:r.at(-1))===i}))}const he={cart:_,customer:ne,estimateShippingMethods:ae,regions:le,storeConfig:ue,countryList:oe};function ve(e,t){return t.split(".").reduce((i,r)=>i&&i[r]!==void 0?i[r]:void 0,e)}const k={cart:null,customer:null,estimateShippingMethods:null,regions:null,storeConfig:null,countryList:null};async function pe(e){const{defaultValueOnFail:t,query:i,options:r,path:o,signalType:s,type:a,transformer:f}=e,u=he[s],v=Symbol();k[s]=v,u.value={...u.value,pending:!0};try{const{data:p,errors:R}=await(a==="mutation"?fe(()=>w(i,r).catch(U)):w(i,{method:"GET",cache:"no-cache",...r}).catch(U));if(R){const q=de(R);if(q.length>0)throw new J(q)}let E=ve(p,o);if(E===void 0)throw new Error(`No data found at path: ${o}`);return f&&(E=f(E)),u.value={...u.value,data:E},setTimeout(()=>{u.value={...u.value,pending:k[s]===v?!1:u.value.pending}},0),E}catch(p){if(t)return u.value={pending:!1,data:t},t;if(p.name==="AbortError")return;throw u.value={...u.value,pending:!1},p}}const _e={cartId:null,authenticated:!1},ke=new Proxy(_e,{set(e,t,i){return e[t]=i,!0},get(e,t){return e[t]}}),ge=e=>e?e.filter(Boolean).filter(i=>(i==null?void 0:i.label)&&(i==null?void 0:i.value)).map(i=>({text:i.label,value:i.value})):[],ye=e=>e?e.filter(Boolean).filter(t=>(t==null?void 0:t.name)&&(t==null?void 0:t.value)):[],me=e=>e?e.filter(Boolean).map(i=>({code:i.code,defaultValue:i.default_value||void 0,frontendInput:i.frontend_input||void 0,isDisabled:!1,isRequired:i.is_required,label:i.label||void 0,multilineCount:i.multiline_count||void 0,options:ge(i.options),sortOrder:i.sort_order||void 0,validateRules:ye(i.validate_rules)})):[],Se=e=>e==null,Ee=(e,t)=>e.amount.value-t.amount.value,j=e=>!(!e||!e.method_code||!e.method_title||Se(e.amount.value)||!e.amount.currency),V=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}}}),Fe=e=>{if(j(e))return V(e)},$e=e=>{if(e)return e.filter(j).map(t=>V(t)).sort(Ee)},Te=`
|
|
2
|
+
query getStoreConfig {
|
|
3
|
+
storeConfig {
|
|
4
|
+
countries_with_required_region
|
|
5
|
+
default_country
|
|
6
|
+
display_state_if_optional
|
|
7
|
+
is_guest_checkout_enabled
|
|
8
|
+
is_one_page_checkout_enabled
|
|
9
|
+
locale
|
|
10
|
+
optional_zip_countries
|
|
11
|
+
shopping_cart_display_shipping
|
|
12
|
+
store_code
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`;var g=(e=>(e.EXCLUDING_TAX="EXCLUDING_TAX",e.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",e.INCLUDING_TAX="INCLUDING_TAX",e))(g||{});const Ce="US",h={defaultCountry:Ce,countriesWithRequiredRegion:[],displayStateIfOptional:!1,countriesWithOptionalZipCode:[],isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1,shoppingCartDisplaySetting:{shipping:g.EXCLUDING_TAX}},Pe=async()=>await pe({type:"query",query:Te,options:{method:"GET",cache:"no-cache"},path:"storeConfig",signalType:"storeConfig",transformer:xe,defaultValueOnFail:h});function be(e){switch(e){case 1:return g.EXCLUDING_TAX;case 2:return g.INCLUDING_TAX;case 3:return g.INCLUDING_EXCLUDING_TAX;default:return g.EXCLUDING_TAX}}function xe(e){if(!e)return h;const{default_country:t,countries_with_required_region:i,display_state_if_optional:r,optional_zip_countries:o,is_guest_checkout_enabled:s,is_one_page_checkout_enabled:a,shopping_cart_display_shipping:f}=e;return{defaultCountry:t||h.defaultCountry,countriesWithRequiredRegion:(i==null?void 0:i.split(","))||h.countriesWithRequiredRegion,displayStateIfOptional:r||h.displayStateIfOptional,countriesWithOptionalZipCode:(o==null?void 0:o.split(","))||h.countriesWithOptionalZipCode,isGuestCheckoutEnabled:s||h.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:a||h.isOnePageCheckoutEnabled,shoppingCartDisplaySetting:{shipping:be(f)}}}const{setEndpoint:He,setFetchGraphQlHeader:Be,removeFetchGraphQlHeader:We,setFetchGraphQlHeaders:Qe,fetchGraphQl:w,getConfig:je}=new Y().getMethods(),Ie=`
|
|
2
16
|
query fetchAddressFormFields {
|
|
3
17
|
attributesForm(formCode: "customer_register_address") {
|
|
4
18
|
items {
|
|
@@ -27,4 +41,4 @@ import{events as Q}from"@dropins/tools/event-bus.js";import{Component as j,optio
|
|
|
27
41
|
}
|
|
28
42
|
}
|
|
29
43
|
}
|
|
30
|
-
`,
|
|
44
|
+
`,Ne=e=>{if(!(!e||e.length===0))throw Error(e.map(t=>t.message).join(" "))},Ve=async()=>w(Ie,{method:"GET",cache:"no-cache"}).then(({data:e,errors:t})=>(Ne(t),me(e.attributesForm.items))).catch(U);var c=(e=>(e.Boolean="BOOLEAN",e.Date="DATE",e.Datetime="DATETIME",e.File="FILE",e.Gallery="GALLERY",e.Hidden="HIDDEN",e.Image="IMAGE",e.MediaImage="MEDIA_IMAGE",e.Multiline="MULTILINE",e.Multiselect="MULTISELECT",e.Price="PRICE",e.Select="SELECT",e.Text="TEXT",e.Textarea="TEXTAREA",e.Undefined="UNDEFINED",e.Weight="WEIGHT",e))(c||{}),De=(e=>(e.DateRangeMax="DATE_RANGE_MAX",e.DateRangeMin="DATE_RANGE_MIN",e.FileExtensions="FILE_EXTENSIONS",e.InputValidation="INPUT_VALIDATION",e.MaxFileSize="MAX_FILE_SIZE",e.MaxImageHeight="MAX_IMAGE_HEIGHT",e.MaxImageWidth="MAX_IMAGE_WIDTH",e.MaxTextLength="MAX_TEXT_LENGTH",e.MinTextLength="MIN_TEXT_LENGTH",e))(De||{});const Ze=[{frontendInput:c.Text,code:"firstname",label:"First Name",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:10},{frontendInput:c.Text,code:"lastname",label:"Last Name",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:20},{frontendInput:c.Text,code:"company",label:"Company",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:30},{frontendInput:c.Multiline,code:"street",label:"Street Address",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:40},{frontendInput:c.Text,code:"city",label:"City",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:50},{frontendInput:c.Select,code:"country_id",label:"Country",isRequired:!0,isDisabled:!1,options:[{text:"United States",value:"US"},{text:"Spain",value:"ES"},{text:"France",value:"FR"}],validateRules:[],sortOrder:60},{frontendInput:c.Text,code:"region",label:"State/Province",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:70},{frontendInput:c.Hidden,code:"region_id",label:"State/Province",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:80},{frontendInput:c.Text,code:"postcode",label:"Zip/Postal Code",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:90},{frontendInput:c.Text,code:"telephone",label:"Phone Number",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:100},{frontendInput:c.Text,code:"vat_id",label:"VAT Number",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:110}];export{c as A,oe as B,Ce as D,J as F,C as I,Ge as M,h as S,g as T,we as U,De as V,Le as a,Re as b,qe as c,Xe as d,Be as e,Qe as f,w as g,je as h,Ve as i,Ze as j,Pe as k,se as l,ne as m,_ as n,ke as o,pe as p,ue as q,We as r,He as s,$e as t,Fe as u,U as v,Ne as w,d as x,ae as y,le as z};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as a,
|
|
1
|
+
import{t as a,u as l}from"./fixtures.js";const c=e=>{if(e)return{code:e.code,title:e.title}},d=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:r,title:i}=t;return{code:r,title:i}})},u=e=>e?!!e.code&&!!e.label:!1,m=e=>{if(!u(e))return;const{code:t,label:r,region_id:i}=e;return i?{code:t,name:r,id:i}:{code:t,name:r}},_=e=>{const{code:t,label:r}=e;return{value:t,label:r}},p=e=>e?"code"in e&&"value"in e:!1,h=e=>e.filter(p).map(t=>{const{code:r,value:i}=t;return{code:r,value:i}}),o=e=>{const t=e.street.filter(Boolean);return{firstName:e.firstname,lastName:e.lastname,company:e.company||void 0,city:e.city,street:t,postCode:e.postcode||void 0,vatId:e.vat_id||void 0,telephone:e.telephone||void 0,region:m(e.region),country:_(e.country),customAttributes:h(e.custom_attributes)}},y=e=>{if(e)return o(e)},g=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:r,selected_shipping_method:i,...n}=t;return{...o(n),availableShippingMethods:a(r),selectedShippingMethod:l(i)}}),f=e=>({availablePaymentMethods:d(e.available_payment_methods),billingAddress:y(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:c(e.selected_payment_method),shippingAddresses:g(e.shipping_addresses)}),s=`
|
|
2
2
|
fragment CheckoutData on Cart {
|
|
3
3
|
is_virtual
|
|
4
4
|
email
|
|
@@ -81,6 +81,14 @@ import{t as a,a as l}from"./transform-shipping-methods.js";const c=e=>{if(e)retu
|
|
|
81
81
|
carrier_title
|
|
82
82
|
method_code
|
|
83
83
|
method_title
|
|
84
|
+
price_excl_tax {
|
|
85
|
+
value
|
|
86
|
+
currency
|
|
87
|
+
}
|
|
88
|
+
price_incl_tax {
|
|
89
|
+
value
|
|
90
|
+
currency
|
|
91
|
+
}
|
|
84
92
|
}
|
|
85
93
|
}
|
|
86
94
|
available_payment_methods {
|
|
@@ -99,7 +107,7 @@ import{t as a,a as l}from"./transform-shipping-methods.js";const c=e=>{if(e)retu
|
|
|
99
107
|
...CheckoutData
|
|
100
108
|
}
|
|
101
109
|
}
|
|
102
|
-
${
|
|
110
|
+
${s}
|
|
103
111
|
`,C=`
|
|
104
112
|
query getCustomerCart {
|
|
105
113
|
cart: customerCart {
|
|
@@ -107,5 +115,5 @@ import{t as a,a as l}from"./transform-shipping-methods.js";const c=e=>{if(e)retu
|
|
|
107
115
|
...CheckoutData
|
|
108
116
|
}
|
|
109
117
|
}
|
|
110
|
-
${
|
|
111
|
-
`;export{
|
|
118
|
+
${s}
|
|
119
|
+
`;export{s as C,C as a,b as g,f as t};
|