@dropins/storefront-checkout 0.1.0-alpha36 → 0.1.0-alpha38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/getStoreConfig/getStoreConfig.d.ts +3 -1
- package/api/utils/dispatchApiCall.d.ts +11 -6
- 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 +2 -2
- package/chunks/address-form-fields2.js +1 -0
- package/chunks/fixtures.js +30 -0
- package/chunks/getCart.graphql.js +1 -1
- package/chunks/getCountries.js +7 -0
- package/chunks/initialize.js +14 -1
- package/chunks/placeOrder2.js +3 -3
- package/chunks/services.js +1 -0
- package/chunks/setBillingAddress.js +3 -3
- package/chunks/setGuestEmailOnCart.js +3 -3
- package/chunks/setPaymentMethod.js +3 -3
- package/chunks/setShippingAddress.js +3 -3
- package/chunks/setShippingMethods.js +3 -3
- package/chunks/transform-shipping-methods.js +1 -1
- package/containers/BillToShippingAddress.js +1 -1
- package/containers/BillingForm.js +1 -1
- package/containers/Checkout.js +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/context/index.d.ts +0 -1
- package/package.json +1 -1
- package/render.js +1 -1
- package/signals/StoreConfigSignal.d.ts +7 -0
- package/signals/index.d.ts +1 -0
- package/chunks/getStoreConfig.js +0 -49
- package/context/store.d.ts +0 -12
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { StoreConfig } from '../../data/models';
|
|
2
2
|
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const DEFAULT_COUNTRY = "US";
|
|
4
|
+
export declare const STORE_CONFIG_DEFAULTS: StoreConfig;
|
|
5
|
+
export declare const getStoreConfig: () => Promise<StoreConfig | undefined>;
|
|
4
6
|
//# sourceMappingURL=getStoreConfig.d.ts.map
|
|
@@ -5,6 +5,14 @@ declare const signalTypes: {
|
|
|
5
5
|
pending: boolean;
|
|
6
6
|
data?: import('../../data/models/cart').Cart | null | undefined;
|
|
7
7
|
}>;
|
|
8
|
+
customer: import('@preact/signals-core').Signal<{
|
|
9
|
+
pending: boolean;
|
|
10
|
+
data?: import('../../data/models/customer').Customer | null | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
estimateShippingMethods: import('@preact/signals-core').Signal<{
|
|
13
|
+
pending: boolean;
|
|
14
|
+
data?: import('../../data/models/shipping-method').ShippingMethod[] | undefined;
|
|
15
|
+
}>;
|
|
8
16
|
regions: import('@preact/signals-core').Signal<{
|
|
9
17
|
addressType?: import('../../data/models/address-form-fields').AddressFormType | undefined;
|
|
10
18
|
country?: string | undefined;
|
|
@@ -13,13 +21,9 @@ declare const signalTypes: {
|
|
|
13
21
|
pending: boolean;
|
|
14
22
|
data?: import('../../data/models/region').Region[] | undefined;
|
|
15
23
|
}>;
|
|
16
|
-
|
|
24
|
+
storeConfig: import('@preact/signals-core').Signal<{
|
|
25
|
+
data?: import('../../data/models/store-config').StoreConfig | undefined;
|
|
17
26
|
pending: boolean;
|
|
18
|
-
data?: import('../../data/models/shipping-method').ShippingMethod[] | undefined;
|
|
19
|
-
}>;
|
|
20
|
-
customer: import('@preact/signals-core').Signal<{
|
|
21
|
-
pending: boolean;
|
|
22
|
-
data?: import('../../data/models/customer').Customer | null | undefined;
|
|
23
27
|
}>;
|
|
24
28
|
};
|
|
25
29
|
type SignalTypesType = typeof signalTypes;
|
|
@@ -34,6 +38,7 @@ type DispatchApiCallParams<T extends SignalTypesKeys> = {
|
|
|
34
38
|
path: string;
|
|
35
39
|
signalType: T;
|
|
36
40
|
transformer?: (data: any) => SignalDataMap[T];
|
|
41
|
+
defaultValueOnFail?: SignalDataMap[T];
|
|
37
42
|
};
|
|
38
43
|
export declare function getValueAtPath(obj: any, path: string): any;
|
|
39
44
|
declare function dispatchApiCall<T extends SignalTypesKeys>(params: DispatchApiCallParams<T>): Promise<SignalDataMap[T]>;
|
package/api.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as l,I as h,c as f,M as c,d as x,a as A,b as
|
|
1
|
+
import{F as l,I as h,c as f,M as c,d as x,a as A,b as F,U as C,j as E,i as M,g as S,h as T,r as u,s as G,e as O,f as U}from"./chunks/fixtures.js";import{e as R,g as I}from"./chunks/address-form-fields.js";import{g as _,a as v,p as y}from"./chunks/placeOrder2.js";import{g as H}from"./chunks/getCountries.js";import{D as b,S as w,c as L,g as P,i as j}from"./chunks/initialize.js";import{i as Y,s as k}from"./chunks/setGuestEmailOnCart.js";import{s as J}from"./chunks/setBillingAddress.js";import{s as V}from"./chunks/setPaymentMethod.js";import{S as X,p as Z,s as $}from"./chunks/setShippingAddress.js";import{s as es}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/transform-shipping-methods.js";import"./chunks/getCart.graphql.js";import"@dropins/tools/lib.js";const m=e=>{var s;(s=window==null?void 0:window.location)==null||s.assign(e)};export{b as DEFAULT_COUNTRY,l as FetchError,h as InvalidArgument,f as MissingBillingAddress,c as MissingCart,x as MissingCountry,A as MissingEmail,F as MissingPaymentMethod,X as STANDARD_ATTRIBUTES,w as STORE_CONFIG_DEFAULTS,C as UnexpectedError,L as config,E as defaultFormFields,R as estimateShippingMethods,M as fetchAddressFormFields,S as fetchGraphQl,_ as getCart,T as getConfig,H as getCountries,v as getCustomer,I as getRegions,P as getStoreConfig,j as initialize,Y as isEmailAvailable,y as placeOrder,Z as prepareAddress,m as redirect,u as removeFetchGraphQlHeader,J as setBillingAddress,G as setEndpoint,O as setFetchGraphQlHeader,U as setFetchGraphQlHeaders,k as setGuestEmailOnCart,V as setPaymentMethod,$ as setShippingAddress,es as setShippingMethodsOnCart};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@dropins/tools/event-bus.js";import{
|
|
1
|
+
import"@dropins/tools/event-bus.js";import{k as p,m 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-fields2.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{l as A,m as B,k as F}from"./fixtures.js";import{s as b}from"./setBillingAddress.js";import{p as h}from"./setShippingAddress.js";import{A as v}from"./ToggleButton.js";import"@dropins/tools/preact-hooks.js";import{u as I}from"./address-form-fields2.js";import"./services.js";import{A as k}from"./address-form-fields.js";import"@dropins/tools/lib.js";import{c as y}from"./BillToShippingAddress2.js";import{useRef as S,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 J=u=>{var f;const l=S(null),{fields:i}=I(),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=>b({signal:e.signal,cartId:a,input:{address:r?void 0:h(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(v,{...u,addressType:k.BILLING,autoFill:g,"data-testid":"billing-form",headingId:"Checkout.BillingAddress.title",name:N,ref:l,saveAddressHandler:c,style:{display:d?"block":"none"}})};export{J 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{m as M,l as T,t as z}from"./fixtures.js";import{i as V,s as $}from"./setGuestEmailOnCart.js";import{Field as j,Input as q,Divider as G}from"@dropins/tools/components.js";import{jsx as o,jsxs as m,Fragment as O}from"@dropins/tools/preact-jsx-runtime.js";import{H as P,p as w}from"./ToggleButton.js";import{useState as E,useEffect as R}from"@dropins/tools/preact-hooks.js";import"./address-form-fields2.js";import"./services.js";import{classes as N}from"@dropins/tools/lib.js";/* empty css */import{useText as k,Text as f}from"@dropins/tools/i18n.js";import{L as U}from"./constants3.js";const J=({value:r,error:l,hint:a,onChange:c,onBlur:u,onInvalid:n})=>{const i=k({LoginFormLabel:"Checkout.LoginForm.ariaLabel",LoginFormFloatingLabel:"Checkout.LoginForm.floatingLabel",LoginFormPlaceholder:"Checkout.LoginForm.placeholder"});return o(j,{size:"medium",error:l,hint:a,children:o(q,{id:"customer-email",name:"customer-email",type:"email",value:r,autocomplete:"email",placeholder:i.LoginFormPlaceholder,floatingLabel:i.LoginFormFloatingLabel,onChange:c,onBlur:u,onInvalid:n,required:!0,"aria-label":i.LoginFormLabel,"aria-required":!0})})},K=({onSignInClick:r,email:l})=>m("div",{className:"checkout-login-form__sign-in",children:[o(f,{id:"Checkout.LoginForm.account"}),o("a",{"data-testid":"sign-in-link",className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:a=>{a.preventDefault(),r==null||r(l)},children:o(f,{id:"Checkout.LoginForm.signIn"})})]}),Q=({name:r,className:l,currentEmail:a,hint:c,error:u=null,onEmailChange:n,onEmailBlur:i,onEmailInvalid:F,onSignInClick:L,onSignOutClick:v,isAuthenticated:p,customer:e,...g})=>{const d=k({Title:"Checkout.LoginForm.title"});return m("div",{...g,className:N(["checkout-login-form",l]),"data-testid":"checkout-login-form",children:[m("div",{className:"checkout-login-form__heading",children:[o(P,{level:2,className:"checkout-login-form__title",children:d.Title}),p?o(W,{onSignOutClick:v}):o(K,{onSignInClick:L,email:a})]}),e?m("div",{className:"checkout-login-form__customer-details",children:[o("div",{className:"checkout-login-form__customer-name",children:`${e==null?void 0:e.firstName} ${e==null?void 0:e.lastName}`}),o("div",{className:"checkout-login-form__customer-email",children:e==null?void 0:e.email})]}):o("div",{className:"checkout-login-form__content",children:m("form",{className:N(["dropin-login-form__form",l]),name:r,noValidate:!0,children:[o("button",{type:"submit",disabled:!0,style:"display: none","aria-hidden":"true"}),o(J,{value:a||void 0,error:u||"",hint:c,onChange:n,onBlur:i,onInvalid:F})]})}),o(G,{variant:"primary"})]})},W=({onSignOutClick:r})=>m("p",{className:"checkout-login-form__sign-out",children:[o(f,{id:"Checkout.LoginForm.switch"}),o("a",{className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:l=>{l.preventDefault(),r==null||r()},children:o(f,{id:"Checkout.LoginForm.signOut"})})]}),X=r=>w.email.test(r),Y=1e3,ue=({className:r,email:l=null,onSignInClick:a,onSignOutClick:c,...u})=>{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:i}=M.value,F=(i==null?void 0:i.id)||"",L=!!i,[v,p]=E(!1),[e,g]=E(l),[d,h]=E(),[x,_]=E(!0),b=t=>t.valid?null:t.valueMissing?n.LoginFormMissingEmailError:n.LoginFormInvalidEmailError,C=T.value.data,y=t=>{const{value:s}=t.target;g(s),h(null),_(!0)},A=t=>{const{validity:s}=t.target;h(b(s))},I=t=>{const{validity:s}=t.target;h(b(s))};!v&&L&&(p(!0),g((i==null?void 0:i.email)||l)),R(()=>{if(!e||d)return;const t=setTimeout(()=>{V(e).then(s=>{_(s),(i==null?void 0:i.email)!==e&&$(e).catch(H=>{console.log("set email failed",H)})}).catch(s=>{console.log(s),h(n.LoginFormInvalidEmailError),_(!0)})},Y);return()=>{t&&clearTimeout(t)}},[e,d,n.LoginFormInvalidEmailError,i==null?void 0:i.email,F]);const B=x?"":m(O,{children:[n.LoginFormEmailExistsAlreadyHaveAccount," ",o("a",{href:"#",onClick:t=>{t.preventDefault(),a==null||a(e)},children:n.LoginFormEmailExistsSignInButton})," ",n.LoginFormEmailExistsForFasterCheckout]});return o(Q,{className:r,currentEmail:e,error:d,hint:B,name:U,onEmailBlur:A,onEmailChange:y,onEmailInvalid:I,onSignInClick:t=>{const s=e?X(e):!1;a==null||a(s?t:null)},onSignOutClick:c,isAuthenticated:!!z.value,customer:C,...u})};export{ue 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{m as s}from"./fixtures.js";/* empty css */import"@dropins/tools/preact-compat.js";import"./address-form-fields2.js";import"@dropins/tools/preact-hooks.js";import"./services.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:t,children:o,...e})=>{const{onClick:r=()=>{},isLoading:n}=e;return i("div",{className:c(["checkout-place-order",t]),children:i(l,{className:c(["checkout-place-order__button",t]),size:"medium",variant:"primary",type:"submit",onClick:r,disabled:n,children:i(a,{id:"Checkout.PlaceOrder.button"})},"placeOrder")})},u=[d,f,m],h=t=>{const o=t.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()),e=o.length===0;if(!e){const r=o[0];h(r)}return e},A=t=>{const{onClick:o,handleServerError:e}=t;return i(p,{onClick:async()=>{if(O())try{await o()}catch(n){e(n)}},isLoading:s.value.pending})};export{A 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{k as o}from"./fixtures.js";import{s as t}from"./setBillingAddress.js";import{s as m,p as a}from"./setShippingAddress.js";import{A as d}from"./ToggleButton.js";import"@dropins/tools/preact-hooks.js";import"./address-form-fields2.js";import"./services.js";import{A as n}from"./address-form-fields.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 N=({preselectedFields:i,...e})=>{const r=o.value.checked,p=l(s=>m({signal:s.signal,address:a(s.address)}).then(()=>{if(r)return t({input:{same_as_shipping:!0}})}),[r]);return g(d,{...e,addressType:n.SHIPPING,headingId:"Checkout.ShippingAddress.title",name:h,preselectedFields:i,saveAddressHandler:p})};export{N as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as
|
|
1
|
+
import{e as z}from"./address-form-fields.js";import{u as B,v as L,m as b,w as O,x as P}from"./fixtures.js";import{events as N}from"@dropins/tools/event-bus.js";import{s as D}from"./setShippingMethods.js";import{classes as H}from"@dropins/tools/lib.js";import{H as V}from"./ToggleButton.js";import{IllustratedMessage as Z,Icon as $,ProgressSpinner as q,RadioButton as F,Price as G,Divider as J,Skeleton as K,SkeletonRow as _}from"@dropins/tools/components.js";import{useState as T,useEffect as y}from"@dropins/tools/preact-hooks.js";import"./address-form-fields2.js";import"./services.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(V,{level:3,className:"checkout-shipping-methods__title",children:u.Title}),!n&&o.length===0&&i(Z,{icon:i($,{source:ne}),message:i("p",{children:u.EmptyState})}),x("div",{className:H(["checkout-shipping-methods__content"]),children:[n&&i(q,{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]=T(),[a,o]=T();y(()=>{N.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||N.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,w=U(p=>{if(!S)return;const f={method_code:p.code,carrier_code:p.carrier.code};D([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))&&w(m))},[m,t,g,w]),I(()=>{if(!v||C)return;const{country:p,selectedRegion:f,selectedRegionId:M}=P.value,E=p||(n==null?void 0:n.defaultCountry);E&&z({criteria:{country_code:E,region_name:f,region_id:M}}).catch(R=>{L.value={pending:!1,data:[]},console.error("shipping methods estimation failed:",R)})},[v,C,n]),{isLoading:r||a||u,options:l,selection:m,onSelectionChange:A}}const Ee=({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{Ee as S};
|
package/chunks/ToggleButton.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{events as te}from"@dropins/tools/event-bus.js";import{z as P,l as re,V as L,u as me,B as fe,y as ge,k as he,D as Fe}from"./getStoreConfig.js";import{b as J,a as p,A as R,e as pe,D as U,g as ve,M as K,c as Q}from"./address-form-fields.js";import{r as y}from"./transform-shipping-methods.js";import{useState as q,useEffect as z,useCallback as V,useRef as Ie,useMemo as Ee}from"@dropins/tools/preact-hooks.js";import{classes as O,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 ke,SkeletonRow as k,ProgressSpinner as Se}from"@dropins/tools/components.js";/* empty css */import{jsx as a,Fragment as ae,jsxs as B}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}}),Ne=e=>e?e.map(t=>({text:t.label,value:t.value})):[];function we({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,N=c.isDisabled,w=c.isRequired,S=[],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&&(S=Ne(r),t===R.SHIPPING&&(y.value.country=l,A=g=>{const M=g.target,{value:$}=M;$&&T({country_code:$}),h(g),F()})),c.code===p.RegionId&&t===R.SHIPPING&&(y.value.selectedRegionId=l),c.code===p.Region&&(t===y.value.addressType&&(N=y.value.pending),w=s.countriesWithRequiredRegion.includes(e==null?void 0:e.country_id),S=De(o),!w&&!s.displayStateIfOptional&&(m=P.Undefined),m=S.length>0?P.Select:P.Text,m===P.Select?t===R.SHIPPING?(y.value.selectedRegion=l,A=g=>{const $=g.target.value;T({country_code:y.value.country,region_id:$}),h(g),C($)}):A=g=>{h(g);const $=g.target.value;C($)}:m===P.Text&&t===R.SHIPPING&&(y.value.selectedRegion=l,D=g=>{const M=g.target,{value:$}=M;y.value.country&&T({country_code:y.value.country,region_name:$}),v(g)}),l=S.length>0?((I=S.find(g=>g.value===l))==null?void 0:I.value)||"":l),c.code===p.PostCode&&(w=!s.countriesWithOptionalZipCode.includes(e==null?void 0:e.country_id)),{...c,error:b,frontendInput:m,handleSelect:A,isDisabled:N,isRequired:w,onBlur:f,onChange:D,onInvalid:i,options:S,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(()=>{pe({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 L.DateRangeMax:return{...t,max:r.value};case L.DateRangeMin:return{...t,min:r.value};case L.FileExtensions:return{...t,accept:r.value};case L.InputValidation:return{...t,pattern:Be(r.value)};case L.MaxFileSize:case L.MaxImageHeight:case L.MaxImageWidth:return t;case L.MaxTextLength:return{...t,maxLength:r.value};case L.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}`)}},Oe=e=>B(ke,{...e,children:[a(k,{variant:"heading",size:"medium"}),a(k,{variant:"empty",size:"medium"}),a(k,{size:"large"}),a(k,{size:"large"}),a(k,{size:"large",fullWidth:!0}),a(k,{size:"large",fullWidth:!0,lines:3}),a(k,{size:"large"}),a(k,{size:"large"}),a(k,{size:"large"}),a(k,{size:"large"}),a(k,{size:"large"}),a(k,{size:"large"}),a(k,{size:"large"})]}),Ue=({addressType:e,className:t,fields:r,formRef:o,headingId:s,name:u,...n})=>B("div",{...n,className:O(["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:O(["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}ve(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=he.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,N)=>{F[`${m.code}${K}${N}`]=D}):F[m.code]=m.value}),o({values:F,triggerAutoSave:h})},[t,e,f,n,s,v,d,o,r])}const bt=Me(({addressType:e,autoFill:t=!0,children:r,headingId:o,name:s,preselectedFields:u,saveAddressHandler:n,...d},f)=>{const{fields:v}=me(),{countries:i}=fe(),h=i===void 0,E=v===void 0,{config:F}=ge(),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:N,onBlur:w,dismissError:S,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:N,dismissError:S}),E||h||C)return a(Oe,{"data-testid":`${e}-skeleton`});const ue=we({address:A,addressType:e,availableCountries:i,availableRegions:$,config:F,dismissError:S,errors:D,fields:v,onBlur:w,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}=Fe(),[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=Ie(!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)},N=l=>{const I=l.target;F(I)},w=l=>{const I=l.target,{name:g,value:M}=I;m(g,M),F(I)},S=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:w,onBlur:S,onInvalid:N,setAddress:f}},et={countryCode:p.Country,region:p.Region,postCode:p.PostCode};function tt({fields:e,preselectedFields:t}){return Ee(()=>!(!!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})=>B(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})=>B("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})=>B("div",{"data-testid":"checkout",className:O(["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:O(["checkout-overlay-loader",e]),children:a(Se,{})})};export{bt as A,st as C,ce as H,x as p};
|
|
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};
|
package/chunks/ToggleButton2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@dropins/tools/event-bus.js";import{
|
|
1
|
+
import"@dropins/tools/event-bus.js";import{m 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"./address-form-fields2.js";import"./services.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 ye=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{ye as P};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as _,M as y,d as h,o as g,x as l}from"./fixtures.js";import{t as m}from"./transform-shipping-methods.js";import"@dropins/tools/event-bus.js";const I=`
|
|
2
2
|
mutation estimateShippingMethods(
|
|
3
3
|
$cartId: String!
|
|
4
4
|
$address: EstimateAddressInput!
|
|
@@ -29,7 +29,7 @@ mutation estimateShippingMethods(
|
|
|
29
29
|
error_message
|
|
30
30
|
}
|
|
31
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=
|
|
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
33
|
query getRegions($countryCode: String!) {
|
|
34
34
|
country(id: $countryCode) {
|
|
35
35
|
id
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1,30 @@
|
|
|
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=`
|
|
2
|
+
query fetchAddressFormFields {
|
|
3
|
+
attributesForm(formCode: "customer_register_address") {
|
|
4
|
+
items {
|
|
5
|
+
frontend_input
|
|
6
|
+
code
|
|
7
|
+
label
|
|
8
|
+
default_value
|
|
9
|
+
is_required
|
|
10
|
+
options {
|
|
11
|
+
label
|
|
12
|
+
value
|
|
13
|
+
is_default
|
|
14
|
+
}
|
|
15
|
+
... on CustomerAttributeMetadata {
|
|
16
|
+
multiline_count
|
|
17
|
+
sort_order
|
|
18
|
+
validate_rules {
|
|
19
|
+
name
|
|
20
|
+
value
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
errors {
|
|
25
|
+
message
|
|
26
|
+
type
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`,_e=e=>{if(!(!e||e.length===0))throw Error(e.map(t=>t.message).join(" "))},Ue=async()=>A(pe,{method:"GET",cache:"no-cache"}).then(({data:e,errors:t})=>(_e(t),he(e.attributesForm.items))).catch(I);var d=(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))(d||{}),ge=(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))(ge||{});const Ge=[{frontendInput:d.Text,code:"firstname",label:"First Name",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:10},{frontendInput:d.Text,code:"lastname",label:"Last Name",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:20},{frontendInput:d.Text,code:"company",label:"Company",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:30},{frontendInput:d.Multiline,code:"street",label:"Street Address",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:40},{frontendInput:d.Text,code:"city",label:"City",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:50},{frontendInput:d.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:d.Text,code:"region",label:"State/Province",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:70},{frontendInput:d.Hidden,code:"region_id",label:"State/Province",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:80},{frontendInput:d.Text,code:"postcode",label:"Zip/Postal Code",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:90},{frontendInput:d.Text,code:"telephone",label:"Phone Number",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:100},{frontendInput:d.Text,code:"vat_id",label:"VAT Number",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:110}];export{d as A,Z as F,S as I,Ee as M,be as U,ge as V,Te as a,Me as b,we as c,Ie as d,Ne as e,Re as f,A as g,qe as h,Ue as i,Ge as j,ie as k,B as l,X as m,Ae as n,De as o,_e as p,I as q,Oe as r,Ce as s,te as t,c as u,re as v,oe as w,se as x};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as a,
|
|
1
|
+
import{t as a,a as l}from"./transform-shipping-methods.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:o}=t;return{code:r,title:o}})},u=e=>e?!!e.code&&!!e.label:!1,m=e=>{if(!u(e))return;const{code:t,label:r,region_id:o}=e;return o?{code:t,name:r,id:o}:{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:o}=t;return{code:r,value:o}}),s=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 s(e)},g=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:r,selected_shipping_method:o,...n}=t;return{...s(n),availableShippingMethods:a(r),selectedShippingMethod:l(o)}}),v=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)}),i=`
|
|
2
2
|
fragment CheckoutData on Cart {
|
|
3
3
|
is_virtual
|
|
4
4
|
email
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{g as o,p as a,q as l}from"./fixtures.js";const c=t=>{if(t)return t.filter(e=>!!e).filter(e=>{const{two_letter_abbreviation:r,full_name_locale:n}=e;return!!r&&!!n}).map(e=>{const{two_letter_abbreviation:r,full_name_locale:n}=e;return{value:r,label:n}})},u=`
|
|
2
|
+
query getCountries {
|
|
3
|
+
countries {
|
|
4
|
+
two_letter_abbreviation
|
|
5
|
+
full_name_locale
|
|
6
|
+
}
|
|
7
|
+
}`,s=async()=>o(u,{method:"GET",cache:"no-cache"}).then(({data:t,errors:e})=>(e&&a(e),c(t.countries))).catch(l);export{s as g};
|
package/chunks/initialize.js
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{o as d,n as a}from"./fixtures.js";import{Initializer as f}from"@dropins/tools/lib.js";import{events as s}from"@dropins/tools/event-bus.js";const p=`
|
|
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
|
+
store_code
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
`,g="US",t={defaultCountry:g,countriesWithRequiredRegion:[],displayStateIfOptional:!1,countriesWithOptionalZipCode:[],isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1},_=async()=>await d({type:"query",query:p,options:{method:"GET",cache:"no-cache"},path:"storeConfig",signalType:"storeConfig",transformer:C,defaultValueOnFail:t});function C(e){if(!e)return t;const{default_country:i,countries_with_required_region:o,display_state_if_optional:r,optional_zip_countries:n,is_guest_checkout_enabled:l,is_one_page_checkout_enabled:c}=e;return{defaultCountry:i||t.defaultCountry,countriesWithRequiredRegion:(o==null?void 0:o.split(","))||t.countriesWithRequiredRegion,displayStateIfOptional:r||t.displayStateIfOptional,countriesWithOptionalZipCode:(n==null?void 0:n.split(","))||t.countriesWithOptionalZipCode,isGuestCheckoutEnabled:l||t.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:c||t.isOnePageCheckoutEnabled}}const u=new f({init:async e=>{const i={guestViewCookieExpirationDays:30,...e};u.config.setConfig(i),_()},listeners:()=>[s.on("cart/data",e=>{a.cartId=(e==null?void 0:e.id)||null}),s.on("authenticated",e=>{a.authenticated=e},{eager:!0})]}),k=u.config;export{g as D,t as S,k as c,_ as g,u as i};
|
package/chunks/placeOrder2.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as
|
|
1
|
+
import{t as q,g as A,a as E}from"./getCart.graphql.js";import{n as l,M as b,o as d,g as w,q as N,F as k,U as D}from"./fixtures.js";import{events as f}from"@dropins/tools/event-bus.js";const L=t=>({id:l.cartId,totalQuantity:t.totalQuantity,possibleOnepageCheckout:!0,items:t.items.map(n=>{var a;return{canApplyMsrp:!0,formattedPrice:"",id:n.id,quantity:n.totalQuantity,product:{canonicalUrl:n.product.canonicalUrl||"",mainImageUrl:n.product.image||"",name:n.product.name,productId:0,productType:n.product.productType,sku:n.product.sku},prices:{price:{value:n.price.value,currency:n.price.currency}},configurableOptions:((a=n.selectedOptions)==null?void 0:a.map(e=>({optionLabel:e.label,valueLabel:e.value})))||[]}})}),Q=t=>{var e,s,i;const n=t.coupons[0],a=(e=t.payments)==null?void 0:e[0];return{appliedCouponCode:(n==null?void 0:n.code)||"",email:t.email,grandTotal:t.total,orderId:t.number,orderType:"checkout",otherTax:0,salesTax:t.totalTax,shipping:{shippingMethod:((s=t.shipping)==null?void 0:s.code)||"",shippingAmount:((i=t.shipping)==null?void 0:i.amount)||0},subtotalExcludingTax:t.subtotal,subtotalIncludingTax:0,payments:a?[{paymentMethodCode:(a==null?void 0:a.code)||"",paymentMethodName:(a==null?void 0:a.name)||"",total:t.total}]:[]}},R=t=>t?"code"in t&&"value"in t:!1,S=t=>t.filter(R).map(n=>{const{code:a,value:e}=n;return{code:a,value:e}}),T=t=>{var s,i,u;const n=t.street.filter(Boolean),a=(s=t.region)==null?void 0:s.region_id,e=a&&a>0;return{id:String(t.id),firstName:t.firstname,lastName:t.lastname,company:t.company||void 0,city:t.city,street:n,postCode:t.postcode||void 0,vatId:t.vat_id||void 0,telephone:t.telephone||void 0,region:{id:e?a:void 0,code:(i=t.region)==null?void 0:i.region_code,name:(u=t.region)==null?void 0:u.region},country:{value:t.country_code,label:t.country_code},customAttributes:S(t.custom_attributesV2)}},P=t=>t?t.filter(Boolean).map(T):[],m=(t,n)=>{if(!n)return;const a=n.find(e=>(e==null?void 0:e[t])===!0);if(a)return T(a)},V=t=>{if(!t)return;const n=t.addresses;return{firstName:t.firstname||"",lastName:t.lastname||"",email:t.email||"",addresses:P(n),defaultBillingAddress:m("default_billing",n),defaultShippingAddress:m("default_shipping",n)}},o=t=>t||0,M=t=>{var n;return{canonicalUrl:(t==null?void 0:t.canonical_url)||"",id:(t==null?void 0:t.uid)||"",name:(t==null?void 0:t.name)||"",sku:(t==null?void 0:t.sku)||"",image:((n=t==null?void 0:t.image)==null?void 0:n.url)||"",productType:(t==null?void 0:t.__typename)||""}},U=t=>o(t==null?void 0:t.quantity_ordered)+o(t==null?void 0:t.quantity_shipped)+o(t==null?void 0:t.quantity_canceled)+o(t==null?void 0:t.quantity_invoiced)+o(t==null?void 0:t.quantity_refunded)+o(t==null?void 0:t.quantity_returned),F=t=>t?t.map(n=>({id:(n==null?void 0:n.id)||"",price:{value:(n==null?void 0:n.product_sale_price.value)||0,currency:(n==null?void 0:n.product_sale_price.currency)||""},totalQuantity:U(n),product:M(n==null?void 0:n.product)})):[],G=t=>{var p,r,y,g,_,h;const n=((p=t.total)==null?void 0:p.grand_total.value)??0,a=(r=t.payment_methods)==null?void 0:r[0],e=(a==null?void 0:a.type)??"",s=(a==null?void 0:a.name)??"",i=F(t.items),u=i.reduce((c,x)=>c+x.totalQuantity,0);return{coupons:((y=t==null?void 0:t.applied_coupons)==null?void 0:y.map(c=>({code:(c==null?void 0:c.code)??""})))||[],email:t.email??"",items:i,number:t.number,token:t.token,total:n,totalQuantity:u,totalTax:((g=t.total)==null?void 0:g.total_tax.value)??0,subtotal:((_=t.total)==null?void 0:_.subtotal.value)??0,shipping:{amount:((h=t.total)==null?void 0:h.total_shipping.value)??0,code:t.shipping_method??""},payments:[{code:e,name:s}]}},Y=async()=>{const t=l.cartId,n=l.authenticated===!1,a=n?A:E,e=n?{cartId:t}:{};if(n&&!t)throw new b;return await d({type:"query",query:a,options:{method:"POST",cache:"no-cache",variables:e},path:"cart",signalType:"cart",transformer:q})},X=`
|
|
2
2
|
query getCustomer {
|
|
3
3
|
customer {
|
|
4
4
|
firstname
|
|
@@ -31,7 +31,7 @@ import{t as A,g as E,a as q}from"./getCart.graphql.js";import{M as b,e as d,F as
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
`,
|
|
34
|
+
`,Z=async()=>await d({type:"query",query:X,options:{method:"POST",cache:"no-cache"},path:"customer",signalType:"customer",transformer:V}),B=`
|
|
35
35
|
mutation placeOrder($cartId: String!) {
|
|
36
36
|
placeOrder(input: { cart_id: $cartId }) {
|
|
37
37
|
orderV2 {
|
|
@@ -96,4 +96,4 @@ import{t as A,g as E,a as q}from"./getCart.graphql.js";import{M as b,e as d,F as
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
`,v={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},$={PLACE_ORDER:"place-order"};function O(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function C(t,n){const a=O();a.push({[t]:null}),a.push({[t]:n})}function H(t,n){O().push(e=>{const s=e.getState?e.getState():{};e.push({event:t,eventInfo:{...s,...n}})})}function j(t){const n=L(t),a=Q(t);console.debug({shoppingCartContext:n,orderContext:a}),C(v.SHOPPING_CART_CONTEXT,{...n}),C(v.ORDER_CONTEXT,{...a}),H($.PLACE_ORDER)}function z(t){throw t.every(a=>{var e;return(e=a.extensions)==null?void 0:e.category})?new
|
|
99
|
+
`,v={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},$={PLACE_ORDER:"place-order"};function O(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function C(t,n){const a=O();a.push({[t]:null}),a.push({[t]:n})}function H(t,n){O().push(e=>{const s=e.getState?e.getState():{};e.push({event:t,eventInfo:{...s,...n}})})}function j(t){const n=L(t),a=Q(t);console.debug({shoppingCartContext:n,orderContext:a}),C(v.SHOPPING_CART_CONTEXT,{...n}),C(v.ORDER_CONTEXT,{...a}),H($.PLACE_ORDER)}function z(t){throw t.every(a=>{var e;return(e=a.extensions)==null?void 0:e.category})?new k(t):new D(t[0].message)}const I=async()=>{const t=l.cartId;if(!t)throw new b;const{data:n,errors:a}=await w(B,{variables:{cartId:t}}).catch(N);a&&z(a);const e=G(n.placeOrder.orderV2);return j(e),f.emit("checkout/order",e),f.emit("cart/reset",void 0),e};export{Z as a,Y as g,I as p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext as o}from"@dropins/tools/preact.js";import{useContext as n,useReducer as d,useState as I,useEffect as S}from"@dropins/tools/preact-hooks.js";import{jsx as u}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/event-bus.js";import"./fixtures.js";import{g as c}from"./getCountries.js";var P=(r=>(r.EMPTY="EMPTY",r.IN_PROGRESS="IN_PROGRESS",r.INIT="INIT",r.LOADING="LOADING",r.COMPLETE="COMPLETE",r))(P||{}),f=(r=>(r[r.CART_UPDATED=0]="CART_UPDATED",r[r.ORDER_PLACED=1]="ORDER_PLACED",r[r.USER_AUTHENTICATED=2]="USER_AUTHENTICATED",r[r.USER_UNAUTHENTICATED=3]="USER_UNAUTHENTICATED",r[r.USER_SIGN_OUT=4]="USER_SIGN_OUT",r))(f||{});const N=(r,e)=>{const i=s=>s!==void 0?s===null||s!=null&&s.isEmpty?"EMPTY":"IN_PROGRESS":"INIT";let t=r;switch(r){case"INIT":e.type===0&&(t=i(e.payload));break;case"IN_PROGRESS":e.type===1&&(t="COMPLETE"),e.type===2&&(t="LOADING"),e.type===4&&(t="LOADING"),e.type===0&&(t=i(e.payload));break;case"EMPTY":case"LOADING":e.type===3&&(t="EMPTY"),e.type===0&&(t=i(e.payload))}return t},a=o(void 0),_=({children:r})=>{const[e,i]=d(N,"INIT"),t={state:e,dispatch:i};return u(a.Provider,{value:t,children:r})};function m(){const r=n(a);if(r!==void 0)return r;throw new Error("useCheckoutState must be used within a CheckoutStateProvider")}const E=o(void 0);function l({children:r}){const[e,i]=I({});return S(()=>{c().then(t=>i({countries:t}))},[]),u(E.Provider,{value:e,children:r})}function x(){const r=n(E);if(r!==void 0)return r;throw new Error("useCountries must be used within a CountriesProvider")}const T=o({});function y({children:r,services:e}){return u(T.Provider,{value:e,children:r})}function G(){const r=n(T);if(r!==void 0)return r;throw new Error("useServices must be used within a ServicesProvider")}export{l as C,y as S,_ as a,f as b,P as c,x as d,G as e,m as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as e,M as d,c as o,o as l}from"./fixtures.js";import{C as c,t as p}from"./getCart.graphql.js";import{events as g}from"@dropins/tools/event-bus.js";const m=`
|
|
2
2
|
mutation setBillingAddress($cartId: String!, $input: BillingAddressInput!) {
|
|
3
3
|
setBillingAddressOnCart(
|
|
4
4
|
input: { cart_id: $cartId, billing_address: $input }
|
|
@@ -9,5 +9,5 @@ import{M as e,c as d,e as o}from"./transform-shipping-methods.js";import{C as l,
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
${
|
|
13
|
-
`,
|
|
12
|
+
${c}
|
|
13
|
+
`,f=async({signal:a,input:s})=>{const t=e.cartId,{address:i,same_as_shipping:r}=s;if(!t)throw new d;if(!r&&!i)throw new o;const n=await l({type:"mutation",query:m,options:{signal:a,variables:{cartId:t,input:s}},path:"setBillingAddressOnCart.cart",signalType:"cart",transformer:p});return g.emit("cart/updated",t),n};export{f as s};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{a as r,
|
|
1
|
+
import{a as r,g as s,q as e,p as l,n,M as o,o as m}from"./fixtures.js";import"@dropins/tools/event-bus.js";import{C as c,t as E}from"./getCart.graphql.js";const u=a=>!!(a!=null&&a.is_email_available),h=`
|
|
2
2
|
query isEmailAvailable($email: String!) {
|
|
3
3
|
isEmailAvailable(email: $email) {
|
|
4
4
|
is_email_available
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
`,C=async a=>{if(!a)throw new r;const{data:t,errors:i}=await
|
|
7
|
+
`,C=async a=>{if(!a)throw new r;const{data:t,errors:i}=await s(h,{method:"GET",cache:"no-cache",variables:{email:a}}).catch(e);return i&&l(i),u(t.isEmailAvailable)},p=`
|
|
8
8
|
mutation setGuestEmail($cartId: String!, $email: String!) {
|
|
9
9
|
setGuestEmailOnCart(input: { cart_id: $cartId, email: $email }) {
|
|
10
10
|
cart {
|
|
@@ -14,4 +14,4 @@ import{a as r,M as s,e}from"./transform-shipping-methods.js";import{f as l,n,o,i
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
${c}
|
|
17
|
-
`,
|
|
17
|
+
`,f=async a=>{const t=n.cartId;if(!t)throw new o;return await m({type:"mutation",query:p,options:{variables:{cartId:t,email:a}},path:"setGuestEmailOnCart.cart",signalType:"cart",transformer:E})};export{C as i,f as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as r,M as n,b as o,o as s}from"./fixtures.js";import{C as i,t as m}from"./getCart.graphql.js";import{events as d}from"@dropins/tools/event-bus.js";const c=`
|
|
2
2
|
mutation setPaymentMethod($cartId: String!, $paymentMethod: String!) {
|
|
3
3
|
setPaymentMethodOnCart(
|
|
4
4
|
input: { cart_id: $cartId, payment_method: { code: $paymentMethod } }
|
|
@@ -9,5 +9,5 @@ import{M as r,b as o,e as n}from"./transform-shipping-methods.js";import{C as s,
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
${
|
|
13
|
-
`,
|
|
12
|
+
${i}
|
|
13
|
+
`,M=async a=>{const t=r.cartId;if(!t)throw new n;if(!a)throw new o;const e=await s({type:"mutation",query:c,options:{variables:{cartId:t,paymentMethod:a}},path:"setPaymentMethodOnCart.cart",signalType:"cart",transformer:m});return d.emit("cart/updated",t),e};export{M as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as s,b as p,M as u,c as _}from"./address-form-fields.js";import{
|
|
1
|
+
import{a as s,b as p,M as u,c as _}from"./address-form-fields.js";import{n as I,M as g,o as C}from"./fixtures.js";import{C as h,t as m}from"./getCart.graphql.js";import{events as A}from"@dropins/tools/event-bus.js";const l=/^\d+$/,T=t=>{if(l.test(t))return parseInt(t,10)},y=`
|
|
2
2
|
mutation setShippingAddress($cartId: String!, $address: CartAddressInput!) {
|
|
3
3
|
setShippingAddressesOnCart(
|
|
4
4
|
input: { cart_id: $cartId, shipping_addresses: [{ address: $address }] }
|
|
@@ -9,5 +9,5 @@ import{a as s,b as p,M as u,c as _}from"./address-form-fields.js";import{i as I}
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
${
|
|
13
|
-
`,S=["city","company","country_code","firstname","lastname","postcode","region","region_id","save_in_address_book","street","telephone","vat_id"],N=t=>{const a={city:t[s.City],company:t[s.Company],country_code:t[s.Country],firstname:t[s.FirstName],lastname:t[s.LastName],postcode:t[s.PostCode],save_in_address_book:!0,street:p(s.Street,t),telephone:t[s.Telephone],vat_id:t[s.Vat]},r=t[s.Region],i=T(r);i?a.region_id=i:a.region=r;const c=Object.keys(t).filter(e=>!e.startsWith("street")).filter(e=>!S.includes(e)).filter(e=>e!=="country_id").map(e=>{const[n,o]=e.split(u);if(!o)return{attribute_code:n,value:t[e]};const d=p(n,t).join(_);return{attribute_code:n,value:d}}).filter((e,n,o)=>n===o.findIndex(d=>d.attribute_code===e.attribute_code));return c.length>0&&(a.custom_attributes=c),a},U=async({signal:t,address:a})=>{const r=I.cartId;if(!r)throw new g;const i=await
|
|
12
|
+
${h}
|
|
13
|
+
`,S=["city","company","country_code","firstname","lastname","postcode","region","region_id","save_in_address_book","street","telephone","vat_id"],N=t=>{const a={city:t[s.City],company:t[s.Company],country_code:t[s.Country],firstname:t[s.FirstName],lastname:t[s.LastName],postcode:t[s.PostCode],save_in_address_book:!0,street:p(s.Street,t),telephone:t[s.Telephone],vat_id:t[s.Vat]},r=t[s.Region],i=T(r);i?a.region_id=i:a.region=r;const c=Object.keys(t).filter(e=>!e.startsWith("street")).filter(e=>!S.includes(e)).filter(e=>e!=="country_id").map(e=>{const[n,o]=e.split(u);if(!o)return{attribute_code:n,value:t[e]};const d=p(n,t).join(_);return{attribute_code:n,value:d}}).filter((e,n,o)=>n===o.findIndex(d=>d.attribute_code===e.attribute_code));return c.length>0&&(a.custom_attributes=c),a},U=async({signal:t,address:a})=>{const r=I.cartId;if(!r)throw new g;const i=await C({type:"mutation",query:y,options:{signal:t,variables:{cartId:r,address:a}},path:"setShippingAddressesOnCart.cart",signalType:"cart",transformer:m});return A.emit("cart/updated",r),i};export{S,N as p,U as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as a,M as r,o as n}from"./fixtures.js";import{C as p,t as o}from"./getCart.graphql.js";import{events as e}from"@dropins/tools/event-bus.js";const h=`
|
|
2
2
|
mutation setShippingMethods(
|
|
3
3
|
$cartId: String!
|
|
4
4
|
$shippingMethods: [ShippingMethodInput]!
|
|
@@ -12,5 +12,5 @@ import{M as a,e as r}from"./transform-shipping-methods.js";import{i as p}from"./
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
${
|
|
16
|
-
`,
|
|
15
|
+
${p}
|
|
16
|
+
`,m=async s=>{const t=a.cartId;if(!t)throw new r;const i=n({type:"mutation",query:h,options:{variables:{cartId:t,shippingMethods:s}},path:"setShippingMethodsOnCart.cart",signalType:"cart",transformer:o});return e.emit("cart/updated",t),i};export{m as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const u=e=>e==null,i=(e,r)=>e.amount.value-r.amount.value,c=e=>!(!e||!e.method_code||!e.method_title||u(e.amount.value)||!e.amount.currency),n=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}}}),t=e=>{if(c(e))return n(e)},l=e=>{if(e)return e.filter(c).map(r=>n(r)).sort(i)};export{t as a,l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as L,B as P,c as S,B as T}from"../chunks/BillToShippingAddress2.js";import"@dropins/tools/event-bus.js";import"../chunks/fixtures.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setBillingAddress.js";import"../chunks/getCart.graphql.js";import"../chunks/transform-shipping-methods.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";/* empty css */import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"../chunks/address-form-fields2.js";export{L as BILL_TO_SHIPPING_KEY,P as BillToShippingAddress,S as compareAddresses,T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as
|
|
1
|
+
import{B as G,B as O}from"../chunks/BillingForm.js";import{B as b}from"../chunks/constants2.js";import"@dropins/tools/event-bus.js";import"../chunks/fixtures.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setBillingAddress.js";import"../chunks/getCart.graphql.js";import"../chunks/transform-shipping-methods.js";import"../chunks/setShippingAddress.js";import"../chunks/address-form-fields.js";import"../chunks/ToggleButton.js";import"../chunks/address-form-fields2.js";import"@dropins/tools/preact-jsx-runtime.js";import"../chunks/services.js";import"../chunks/getCountries.js";import"@dropins/tools/lib.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";/* empty css */import"@dropins/tools/preact-compat.js";import"../chunks/ErrorBanner.js";import"../chunks/MergedCartBanner.js";import"../chunks/BillToShippingAddress2.js";export{b as BILLING_FORM_NAME,G as BillingForm,O as default};
|
package/containers/Checkout.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{U as
|
|
1
|
+
import{t as z,m as h,n as M,k as Y,U as J}from"../chunks/fixtures.js";import{events as b}from"@dropins/tools/event-bus.js";import{p as Q,g as W,a as X}from"../chunks/placeOrder2.js";import{C as T}from"../chunks/ToggleButton.js";import{useEffect as ee}from"@dropins/tools/preact-hooks.js";import"../chunks/address-form-fields2.js";import{u as O,b as d,c as f}from"../chunks/services.js";import{Slot as k,classes as a}from"@dropins/tools/lib.js";import{Divider as te,IllustratedMessage as A,Icon as N,Button as B}from"@dropins/tools/components.js";/* empty css */import{jsx as t,jsxs as U,Fragment as re}from"@dropins/tools/preact-jsx-runtime.js";import{useText as S,MarkupText as oe}from"@dropins/tools/i18n.js";import{B as ne}from"../chunks/BillToShippingAddress2.js";import{B as ie}from"../chunks/BillingForm.js";import*as r from"@dropins/tools/preact-compat.js";import{useState as C,useCallback as w,useEffect as P}from"@dropins/tools/preact-compat.js";import{L as se}from"../chunks/LoginForm.js";import{P as ae}from"../chunks/ToggleButton2.js";import{P as ce}from"../chunks/PlaceOrder.js";import{S as le}from"../chunks/ShippingForm.js";import{S as pe}from"../chunks/ShippingMethods.js";import"@dropins/tools/preact.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getCart.graphql.js";import"../chunks/transform-shipping-methods.js";import"../chunks/address-form-fields.js";import"../chunks/ErrorBanner.js";import"../chunks/MergedCartBanner.js";import"../chunks/getCountries.js";import"../chunks/setBillingAddress.js";import"../chunks/setShippingAddress.js";import"../chunks/constants2.js";import"../chunks/setGuestEmailOnCart.js";import"../chunks/constants3.js";import"../chunks/setPaymentMethod.js";import"../chunks/constants.js";import"../chunks/setShippingMethods.js";const de=n=>r.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},r.createElement("g",{clipPath:"url(#clip0_102_196)"},r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3601 18.16H6.5601L4.8801 3H2.3501M19.6701 19.59C19.6701 20.3687 19.0388 21 18.2601 21C17.4814 21 16.8501 20.3687 16.8501 19.59C16.8501 18.8113 17.4814 18.18 18.2601 18.18C19.0388 18.18 19.6701 18.8113 19.6701 19.59ZM7.42986 19.59C7.42986 20.3687 6.79858 21 6.01986 21C5.24114 21 4.60986 20.3687 4.60986 19.59C4.60986 18.8113 5.24114 18.18 6.01986 18.18C6.79858 18.18 7.42986 18.8113 7.42986 19.59Z",stroke:"currentColor",strokeLinejoin:"round"}),r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.25 6.37L20.89 8.06L20.14 14.8H6.19",stroke:"currentColor",strokeLinejoin:"round"})),r.createElement("defs",null,r.createElement("clipPath",{id:"clip0_102_196"},r.createElement("rect",{vectorEffect:"non-scaling-stroke",width:19.29,height:19.5,fill:"white",transform:"translate(2.3501 2.25)"})))),me=n=>r.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},r.createElement("g",{clipPath:"url(#clip0_4797_15331)"},r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M10.25 20.91L1.5 17.55V6.51996L10.25 9.92996V20.91Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.24023 4.64001L14.9902 8.06001V11.42",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{className:"error-icon",vectorEffect:"non-scaling-stroke",d:"M19 13.31L15.5 19.37H22.5L19 13.31Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{className:"error-icon",vectorEffect:"non-scaling-stroke",d:"M19.0202 17.11H18.9802L18.9502 15.56H19.0502L19.0202 17.11ZM18.9602 18.29V18.06H19.0502V18.29H18.9602Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19 12.16V6.51996L10.25 9.92996V20.91L14.27 19.37L14.4 19.32",stroke:"currentColor",strokeLinejoin:"round"}),r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M1.5 6.51999L10.25 3.04999L19 6.51999L10.25 9.92999L1.5 6.51999Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),r.createElement("defs",null,r.createElement("clipPath",{id:"clip0_4797_15331"},r.createElement("rect",{width:22,height:18.86,fill:"white",transform:"translate(1 2.54999)"})))),We="OUT_OF_STOCK";function ue(){const{dispatch:n}=O();ee(()=>{const s=b.on("authenticated",e=>{z.value=e,n(e?{type:d.USER_AUTHENTICATED}:{type:d.USER_UNAUTHENTICATED})},{eager:!0});return()=>{s==null||s.off()}},[n])}const Xe=n=>{const{className:s,slots:e,routeHome:m,preselectedCartData:i,onSignInClick:c,onSignOutClick:E,...x}=n,{state:u,dispatch:l}=O(),[L,_]=C(""),F=L!=="",[I,R]=C(),p=h.value.data,g=!!(p!=null&&p.isVirtual),j=S({CheckoutUnexpectedError:"Checkout.ServerError.unexpected"}),V=w(async()=>{p&&(await Q(),h.value={pending:!1},l({type:d.ORDER_PLACED}))},[p,l]),D=o=>{R(()=>o)},Z=async()=>{_(""),p&&await v()},y=o=>{_(o instanceof TypeError||o instanceof J?j.CheckoutUnexpectedError:o.message)},v=w(async()=>{const o=M.cartId,G=M.authenticated;if(!o)h.value={data:null,pending:!1},l({type:d.CART_UPDATED,payload:null});else{h.value={...h.value,pending:!0};const q=await W();G&&await X(),l({type:d.CART_UPDATED,payload:q})}},[l]);ue();const[H,K]=C({});if(P(()=>{u===f.IN_PROGRESS&&K({})},[u]),P(()=>{const o=b.on("cart/data",()=>{v()},{eager:!0});return()=>{o==null||o.off()}},[v]),u===f.COMPLETE)return null;if(u===f.EMPTY)return t(he,{routeHome:m});if(F)return t(ge,{errorMessage:L,onClick:Z});const $=()=>{const o=Y.value.checked?"checkout-billing-form__hidden":"checkout-billing-form__visible";return t(T.Main,{sections:{billingAddress:U(re,{children:[t(k,{name:"BillingForm",className:o,slot:e==null?void 0:e.BillingForm,children:t(ie,{})}),t(te,{className:a([`${o}`,"checkout-billing-form__divider"]),variant:"primary"})]}),billToShippingAddress:g?void 0:t(ne,{},H),login:t(k,{name:"Login",slot:e==null?void 0:e.Login,children:t(se,{onSignInClick:c,onSignOutClick:()=>{l({type:d.USER_SIGN_OUT}),E==null||E()}})}),paymentMethods:t(ae,{isShippingInfoRequired:!g,onPlaceOrder:D,handleServerError:y,paymentMethodsSlot:e==null?void 0:e.PaymentMethods}),placeOrder:t(ce,{onClick:I??V,handleServerError:y}),shippingAddress:g?void 0:t(k,{name:"ShippingForm",slot:e==null?void 0:e.ShippingForm,children:t(le,{preselectedFields:i==null?void 0:i.address})}),shippingMethods:g?void 0:t(k,{name:"ShippingMethods",slot:e==null?void 0:e.ShippingMethods,children:t(pe,{preSelectedMethod:i==null?void 0:i.shippingMethod})})}})};return t(T,{className:s,isLoading:u===f.LOADING,...x,children:$()})},he=({className:n,title:s,routeHome:e,...m})=>{const i=S({Title:"Checkout.EmptyCart.title",Button:"Checkout.EmptyCart.button"});return t(A,{...m,"data-testid":"checkout-empty-cart",className:a(["checkout-empty-cart",n]),heading:s??i.Title,icon:t(N,{className:a(["checkout-empty-cart__icon"]),source:de}),action:e!=null&&e()?t(B,{className:"checkout-empty-cart__button",size:"medium",variant:"primary",type:"submit",href:e==null?void 0:e(),children:i.Button},"routeHome"):void 0})},ge=({className:n,errorMessage:s,contactSupport:e,...m})=>{const{onClick:i}=m,c=S({Title:"Checkout.ServerError.title",Message:"Checkout.ServerError.message",ContactSupport:"Checkout.ServerError.contactSupport",Button:"Checkout.ServerError.button"});return t(A,{"aria-invalid":"true","aria-describedby":"checkout-server-error__message","aria-live":"polite",className:a(["checkout-server-error",n]),"data-testid":"checkout-server-error",heading:s??c.Title,message:U("p",{id:a(["checkout-server-error__message"]),children:[c.Message,t("br",{}),t(oe,{id:"",children:e??c.ContactSupport})]}),icon:t(N,{className:a(["checkout-server-error__icon"]),source:me}),action:t(B,{className:a(["checkout-server-error__button"]),onClick:i,children:c.Button})})};export{Xe as Checkout,We as OUT_OF_STOCK,Xe as default};
|
package/containers/LoginForm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as
|
|
1
|
+
import{L as E}from"../chunks/constants3.js";import{L as I,L as R}from"../chunks/LoginForm.js";import"@dropins/tools/event-bus.js";import"../chunks/fixtures.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setGuestEmailOnCart.js";import"../chunks/getCart.graphql.js";import"../chunks/transform-shipping-methods.js";import"@dropins/tools/components.js";import"@dropins/tools/preact-jsx-runtime.js";import"../chunks/ToggleButton.js";import"../chunks/address-form-fields.js";import"../chunks/address-form-fields2.js";import"../chunks/services.js";import"../chunks/getCountries.js";import"@dropins/tools/lib.js";import"@dropins/tools/i18n.js";/* empty css */import"@dropins/tools/preact-compat.js";import"../chunks/ErrorBanner.js";import"../chunks/MergedCartBanner.js";export{E as LOGIN_FORM_NAME,I as LoginForm,R as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as
|
|
1
|
+
import{P as k,P as q}from"../chunks/ToggleButton2.js";import"@dropins/tools/event-bus.js";import"../chunks/fixtures.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setPaymentMethod.js";import"../chunks/getCart.graphql.js";import"../chunks/transform-shipping-methods.js";import"../chunks/ToggleButton.js";import"../chunks/address-form-fields.js";import"../chunks/address-form-fields2.js";import"@dropins/tools/preact-jsx-runtime.js";import"../chunks/services.js";import"../chunks/getCountries.js";import"@dropins/tools/lib.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";/* empty css */import"@dropins/tools/preact-compat.js";import"../chunks/ErrorBanner.js";import"../chunks/MergedCartBanner.js";export{k as PaymentMethods,q as default};
|
package/containers/PlaceOrder.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as
|
|
1
|
+
import{P as v,P as w}from"../chunks/PlaceOrder.js";import"@dropins/tools/lib.js";import"../chunks/ToggleButton.js";import"@dropins/tools/event-bus.js";import"../chunks/fixtures.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/address-form-fields.js";import"../chunks/transform-shipping-methods.js";import"../chunks/address-form-fields2.js";import"@dropins/tools/preact-jsx-runtime.js";import"../chunks/services.js";import"../chunks/getCountries.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";/* empty css */import"@dropins/tools/preact-compat.js";import"../chunks/ErrorBanner.js";import"../chunks/MergedCartBanner.js";import"../chunks/constants2.js";import"../chunks/constants3.js";import"../chunks/constants.js";export{v as PlaceOrder,w as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as
|
|
1
|
+
import{S as A,S as E}from"../chunks/ShippingForm.js";import{S as H}from"../chunks/constants.js";import"@dropins/tools/event-bus.js";import"../chunks/fixtures.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setBillingAddress.js";import"../chunks/getCart.graphql.js";import"../chunks/transform-shipping-methods.js";import"../chunks/setShippingAddress.js";import"../chunks/address-form-fields.js";import"../chunks/ToggleButton.js";import"../chunks/address-form-fields2.js";import"@dropins/tools/preact-jsx-runtime.js";import"../chunks/services.js";import"../chunks/getCountries.js";import"@dropins/tools/lib.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";/* empty css */import"@dropins/tools/preact-compat.js";import"../chunks/ErrorBanner.js";import"../chunks/MergedCartBanner.js";export{H as SHIPPING_FORM_NAME,A as ShippingForm,E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as
|
|
1
|
+
import{S as q,S as v}from"../chunks/ShippingMethods.js";import"../chunks/address-form-fields.js";import"../chunks/fixtures.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/transform-shipping-methods.js";import"../chunks/setShippingMethods.js";import"../chunks/getCart.graphql.js";import"@dropins/tools/lib.js";import"../chunks/ToggleButton.js";import"../chunks/address-form-fields2.js";import"@dropins/tools/preact-jsx-runtime.js";import"../chunks/services.js";import"../chunks/getCountries.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";/* empty css */import"@dropins/tools/preact-compat.js";import"../chunks/ErrorBanner.js";import"../chunks/MergedCartBanner.js";export{q as ShippingMethods,v as default};
|
package/context/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-checkout", "version": "0.1.0-
|
|
1
|
+
{"name": "@dropins/storefront-checkout", "version": "0.1.0-alpha38", "@dropins/tools": "~0.26.0"}
|
package/render.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function(n,o){try{if(typeof document<"u"){const t=document.createElement("style"),i=o.styleId;for(const e in o.attributes)t.setAttribute(e,o.attributes[e]);t.setAttribute("data-dropin",i),t.appendChild(document.createTextNode(n));const r=document.querySelector('style[data-dropin="sdk"]');if(r)r.after(t);else{const e=document.querySelector('link[rel="stylesheet"], style');e?e.before(t):document.head.append(t)}}}catch(t){console.error("dropin-styles (injectCodeFunction)",t)}})(`.checkout-bill-to-shipping-address{display:grid}.checkout-bill-to-shipping-address label{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);gap:0}
|
|
2
2
|
.checkout-shipping-methods{display:grid}.checkout-shipping-methods__title{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-shipping-methods__content{position:relative;display:block}.checkout-shipping-methods__method{margin-bottom:var(--spacing-medium);width:fit-content;cursor:pointer;font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-shipping-methods__method:last-child{margin-bottom:0}.dropin-radio-button__label .dropin-price{color:var(--color-neutral-800);font-weight:400}.checkout-shipping-methods__options--loading{opacity:.4;pointer-events:none}.checkout-shipping-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0}.checkout-shipping-address__skeleton{display:flex;align-items:flex-start;justify-content:space-between;gap:var(--spacing-medium);flex-wrap:wrap;min-width:384px}.checkout-address-form__company,.checkout-address-form__street{grid-column:1 / -1}.checkout-address-form__street .dropin-input-container{margin-bottom:var(--spacing-medium)}.checkout-address-form__street .dropin-input-container:last-child{margin-bottom:0}.checkout-address-form__street .dropin-field__content{display:grid;grid-auto-flow:row;gap:var(--spacing-xxsmall)}.checkout-address-form__country_id .dropin-picker__options-container,.checkout-address-form__region .dropin-picker__options-container{z-index:100}.checkout-address-form__save{grid-column:1 / -1;justify-self:center}.checkout-fields-form__title{color:var(--color-neutral-800);font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-fields-form__form{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium)}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-fields-form__form{grid-template-columns:1fr}}@media only screen and (min-width: 768px){.dropin-field--multiline{grid-column:span 2}}.checkout__content{display:grid;align-items:start;row-gap:var(--spacing-xbig)}.checkout__banner{margin-bottom:var(--spacing-xbig)}.checkout-title{color:var(--color-neutral-800);font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);border-bottom:var(--shape-border-width-3) solid var(--color-neutral-400);padding-bottom:var(--spacing-xsmall);padding-top:var(--spacing-small);margin:0}.checkout__content .dropin-divider{margin-bottom:0;width:100%}.checkout__content .checkout-billing-form__divider{margin-top:0}.checkout__content .checkout-billing-form__visible{display:block}.checkout__content .checkout-billing-form__hidden{display:none}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout__content{row-gap:var(--spacing-big)}.checkout-cart-summary .dropin-divider{margin:var(--spacing-medium) 0}}.checkout-login-form{display:grid}.checkout-login-form__heading{display:grid;grid-template-columns:repeat(2,1fr [col-start]);grid-auto-rows:max-content}.checkout-login-form__content{grid-auto-rows:max-content}.checkout-login-form__customer-details{display:grid;grid-auto-flow:row;gap:var(--spacing-xxsmall)}.checkout-login-form__customer-name{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.checkout-login-form__customer-email{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);color:var(--color-neutral-700)}.checkout-login-form__title{grid-column-start:1;color:var(--color-neutral-800);font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing);margin-top:0}.checkout-login-form__sign-in,.checkout-login-form__sign-out{grid-column-start:2;color:var(--color-neutral-800);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);justify-self:flex-end;margin-top:var(--spacing-xxsmall)}a.checkout-login-form__link{font:var(--type-body-2-strong-font);margin-left:var(--spacing-xxsmall)}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-login-form__heading{grid-template-columns:repeat(1,1fr [col-start]);grid-template-rows:1fr}.checkout-login-form__sign-in,.checkout-login-form__sign-out{grid-column-start:1;align-self:flex-start;justify-self:flex-start;margin-top:0;margin-bottom:var(--spacing-medium)}}.checkout-payment-methods{position:relative;display:grid}.checkout-payment-methods__title{font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-payment-methods__wrapper{position:relative;display:grid}.checkout-payment-methods__methods{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium)}.checkout-payment-methods__content{margin-top:var(--spacing-medium)}.checkout-payment-methods--full-width{grid-template-columns:1fr}.checkout-payment-methods--loading{opacity:.4;pointer-events:none}.checkout-payment-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0}.checkout__content [data-slot=PaymentMethods]:empty{display:none}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-payment-methods__methods{grid-template-columns:1fr}}.checkout-place-order{display:grid}.checkout-place-order__button{align-self:flex-end;justify-self:flex-end}@media only screen and (min-width:320px) and (max-width: 768px){.checkout-place-order__button{align-self:center;justify-self:stretch}}.checkout-out-of-stock{display:grid}.checkout-out-of-stock__button{margin-top:var(--spacing-medium);align-self:flex-end;justify-self:flex-end}.checkout-out-of-stock__icon .error-icon{color:var(--color-warning-500)}.checkout-overlay-loader{align-items:center;background:var(--color-neutral-50);display:flex;height:100vh;justify-content:center;left:0;opacity:.5;position:fixed;top:0;width:100%;z-index:9999}.checkout-server-error{position:relative;text-align:center;display:grid}.checkout-server-error__icon .error-icon{color:var(--color-alert-500)}.checkout-server-error a{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing)}.checkout-toggle-button{display:block;position:relative;width:100%}.checkout-toggle-button__actionButton{cursor:pointer;background-color:var(--color-neutral-200);border:var(--shape-border-width-1) solid var(--color-neutral-400);border-radius:var(--shape-border-radius-1);font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);padding:var(--spacing-medium);align-items:center;display:grid}.checkout-toggle-button__selected .checkout-toggle-button__actionButton{background-color:var(--color-neutral-50);border:var(--shape-border-width-1) solid var(--color-neutral-800)}.checkout-toggle-button:has(input:focus-visible){outline:0 none;box-shadow:0 0 0 var(--shape-icon-stroke-4) var(--color-neutral-400);-webkit-box-shadow:0 0 0 var(--shape-icon-stroke-4) var(--color-neutral-400);-moz-box-shadow:0 0 0 var(--shape-icon-stroke-4) var(--color-neutral-400);border-radius:var(--shape-border-radius-1)}.checkout-toggle-button__radioButton.dropin-radio-button{cursor:pointer;position:absolute}.checkout-toggle-button__radioButton .dropin-radio-button__label:before{cursor:pointer;margin-right:0}.checkout-toggle-button__radioButton .dropin-radio-button__input:focus-visible+.dropin-radio-button__label:before{box-shadow:0 0 0 var(--shape-border-width-1) var(--color-neutral-600)}.checkout-toggle-button__content{display:flex;align-items:center;justify-content:center;margin-left:var(--spacing-big)}.checkout-toggle-button__icon{height:24px;margin-right:var(--spacing-xsmall)}`,{styleId:"checkout"});
|
|
3
|
-
var p=Object.defineProperty;var
|
|
3
|
+
var p=Object.defineProperty;var g=(r,e,t)=>e in r?p(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var u=(r,e,t)=>(g(r,typeof e!="symbol"?e+"":e,t),t);import{Render as h}from"@dropins/tools/lib.js";import{events as y}from"@dropins/tools/event-bus.js";import"./chunks/fixtures.js";import{c as b}from"./chunks/initialize.js";import{A as v}from"./chunks/address-form-fields2.js";import{S as w,C as O,a as S}from"./chunks/services.js";import{UIProvider as E}from"@dropins/tools/components.js";import{useState as A,useEffect as P,useMemo as I}from"@dropins/tools/preact-hooks.js";import{jsx as i}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/getCountries.js";class M{isAvailable(){return!!window.localStorage}getKeys(){return this.isAvailable()?Object.keys(window.localStorage):[]}setItem(e,t){this.isAvailable()&&window.localStorage.setItem(e,t)}getItem(e){return this.isAvailable()?window.localStorage.getItem(e):null}removeItem(e){this.isAvailable()&&window.localStorage.removeItem(e)}}class j{constructor(e,t){u(this,"namespace");u(this,"repository");this.namespace=e,this.repository=t}namespaced(e){return`${this.namespace}:${e}`}backup(e,t){return this.repository.setItem(this.namespaced(e),JSON.stringify(t))}restore(e){const t=this.repository.getItem(this.namespaced(e));return t?JSON.parse(t):null}remove(e){return this.repository.removeItem(this.namespaced(e))}clear(){this.repository.getKeys().filter(e=>e.startsWith(this.namespace)).forEach(e=>{this.repository.removeItem(e)})}}function C(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var T=function(e){return D(e)&&!L(e)};function D(r){return!!r&&typeof r=="object"}function L(r){var e=Object.prototype.toString.call(r);return e==="[object RegExp]"||e==="[object Date]"||k(r)}var U=typeof Symbol=="function"&&Symbol.for,_=U?Symbol.for("react.element"):60103;function k(r){return r.$$typeof===_}function B(r){return Array.isArray(r)?[]:{}}function s(r,e){return e.clone!==!1&&e.isMergeableObject(r)?o(B(r),r,e):r}function F(r,e,t){return r.concat(e).map(function(a){return s(a,t)})}function N(r,e){if(!e.customMerge)return o;var t=e.customMerge(r);return typeof t=="function"?t:o}function R(r){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(r).filter(function(e){return Object.propertyIsEnumerable.call(r,e)}):[]}function f(r){return Object.keys(r).concat(R(r))}function m(r,e){try{return e in r}catch{return!1}}function K(r,e){return m(r,e)&&!(Object.hasOwnProperty.call(r,e)&&Object.propertyIsEnumerable.call(r,e))}function $(r,e,t){var a={};return t.isMergeableObject(r)&&f(r).forEach(function(n){a[n]=s(r[n],t)}),f(e).forEach(function(n){K(r,n)||(m(r,n)&&t.isMergeableObject(e[n])?a[n]=N(n,t)(r[n],e[n],t):a[n]=s(e[n],t))}),a}function o(r,e,t){t=t||{},t.arrayMerge=t.arrayMerge||F,t.isMergeableObject=t.isMergeableObject||T,t.cloneUnlessOtherwiseSpecified=s;var a=Array.isArray(e),n=Array.isArray(r),c=a===n;return c?a?t.arrayMerge(r,e,t):$(r,e,t):s(e,t)}o.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(a,n){return o(a,n,t)},{})};var x=o,Y=x;const H=C(Y),J={title:"Checkout",LoginForm:{title:"Contact details",account:"Already have an account?",ariaLabel:"Email",invalidEmailError:"Please enter a valid email address.",missingEmailError:"Enter an email address.",emailExists:{alreadyHaveAccount:"It looks like you already have an account.",signInButton:"Sign in",forFasterCheckout:"for a faster checkout."},floatingLabel:"Email *",placeholder:"Enter your email address",signIn:"Sign In",switch:"Do you want to switch account?",signOut:"Sign Out"},ShippingMethods:{title:"Shipping options",emptyState:"This order can't be shipped to the address provided. Please review the address details you entered and make sure they're correct."},ShippingAddress:{title:"Delivery"},BillingAddress:{title:"Billing Address"},AddressForm:{Validity:{badInput:"Provide a valid {field}.",patternMismatch:"Ensure you have entered a correct {field} format.",rangeOverflow:"Choose a valid {field} within the allowed range.",rangeUnderflow:"Choose a valid {field} within the allowed range.",tooLong:"This entry is too long. Keep it under {field} characters.",tooShort:"Use at least {field} characters.",typeMismatch:"Enter a valid {field}.",valueMissing:"Enter a {field}, this field is required."}},BillToShippingAddress:{title:"Bill to shipping address"},PaymentMethods:{title:"Payment",emptyState:"No payment methods available"},OutOfStock:{title:"Out of stock",message:"Your cart contains items that are out of stock or have limited availability. Please review your cart before placing the order.",button:"Review cart",lowInventory:{one:"Last item!",many:"Only {{count}} left!"},alert:"Out of stock!"},PlaceOrder:{button:"Place Order"},ServerError:{title:"We were unable to process your order",contactSupport:"If you continue to have issues, please contact support.",unexpected:"An unexpected error occurred while processing your order. Please try again later.",button:"Try again"},EmptyCart:{title:"Your cart is empty",button:"Start shopping"},ErrorBanner:{genericMessage:"Server error detected. Please check your connection and try again."},MergedCartBanner:{items:{one:"1 item from a previous session was added to your cart. Please review your new subtotal.",many:"{{count}} items from a previous session were added to your cart. Please review your new subtotal."}}},V={Checkout:J},W={default:V},q=({children:r})=>{var c;const[e,t]=A(),a=(c=b.getConfig())==null?void 0:c.langDefinitions;P(()=>{const l=y.on("locale",d=>{d!==e&&t(d)},{eager:!0});return()=>{l==null||l.off()}},[e]);const n=H(W,a??{});return i(E,{lang:e,langDefinitions:n,children:r})},z=({children:r})=>{const e=I(()=>new j("DROPIN__CHECKOUT",new M),[]);return i(w,{services:{backupService:e},children:i(v,{children:i(O,{children:i(S,{children:r})})})})},G=({children:r})=>i(z,{children:i(q,{children:r})}),ue=new h(i(G,{}));export{G as Provider,ue as render};
|
package/signals/index.d.ts
CHANGED
package/chunks/getStoreConfig.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import{FetchGraphQL as Z}from"@dropins/tools/fetch-graphql.js";import{events as z}from"@dropins/tools/event-bus.js";import{Component as J,options as G,isValidElement as V,createContext as y}from"@dropins/tools/preact.js";import{useMemo as L,useContext as S,useState as x,useEffect as N,useReducer as K}from"@dropins/tools/preact-hooks.js";import{jsx as T}from"@dropins/tools/preact-jsx-runtime.js";const w=e=>{throw e instanceof DOMException&&e.name==="AbortError"||z.emit("error",{source:"checkout",type:"network",error:e}),e};var ee=Symbol.for("preact-signals");function D(){if(c>1)c--;else{for(var e,t=!1;_!==void 0;){var i=_;for(_=void 0,m++;i!==void 0;){var r=i.o;if(i.o=void 0,i.f&=-3,!(8&i.f)&&q(i))try{i.c()}catch(o){t||(e=o,t=!0)}i=r}}if(m=0,c--,t)throw e}}var n=void 0,_=void 0,c=0,m=0,C=0;function F(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 f(e){this.v=e,this.i=0,this.n=void 0,this.t=void 0}f.prototype.brand=ee;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 g(function(){var i=t.value,r=n;n=void 0;try{e(i)}finally{n=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=n;n=void 0;try{return this.value}finally{n=e}};Object.defineProperty(f.prototype,"value",{get:function(){var e=F(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(m>100)throw new Error("Cycle detected");this.v=e,this.i++,C++,c++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{D()}}}});function v(e){return new f(e)}function q(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 $(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 k(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 h(e){f.call(this,void 0),this.x=e,this.s=void 0,this.g=C-1,this.f=4}(h.prototype=new f).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===C))return!0;if(this.g=C,this.f|=1,this.i>0&&!q(this))return this.f&=-2,!0;var e=n;try{$(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,k(this),this.f&=-2,!0};h.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)};h.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)}};h.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(h.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=F(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function te(e){return new h(e)}function H(e){var t=e.u;if(e.u=void 0,typeof t=="function"){c++;var i=n;n=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,A(e),r}finally{n=i,D()}}}function A(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 ie(e){if(n!==this)throw new Error("Out-of-order effect");k(this),n=e,this.f&=-2,8&this.f&&A(this),D()}function E(e){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}E.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()}};E.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,H(this),$(this),c++;var e=n;return n=this,ie.bind(this,e)};E.prototype.N=function(){2&this.f||(this.f|=2,this.o=_,_=this)};E.prototype.d=function(){this.f|=8,1&this.f||A(this)};function g(e){var t=new E(e);try{t.c()}catch(i){throw t.d(),i}return t.d.bind(t)}var R;function p(e,t){G[e]=t.bind(null,G[e]||function(){})}function O(e){R&&R(),R=e&&e.S()}function B(e){var t=this,i=e.data,r=oe(i);r.value=i;var o=L(function(){for(var s=t.__v;s=s.__;)if(s.__c){s.__c.__$f|=4;break}return t.__$u.c=function(){var a;!V(o.peek())&&((a=t.base)==null?void 0:a.nodeType)===3?t.base.data=o.peek():(t.__$f|=1,t.setState({}))},te(function(){var a=r.value.value;return a===0?0:a===!0?"":a||""})},[]);return o.value}B.displayName="_st";Object.defineProperties(f.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:B},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});p("__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 f&&(i||(t.__np=i={}),i[o]=s,r[o]=s.peek())}}e(t)});p("__r",function(e,t){O();var i,r=t.__c;r&&(r.__$f&=-2,(i=r.__$u)===void 0&&(r.__$u=i=function(o){var s;return g(function(){s=this}),s.c=function(){r.__$f|=1,r.setState({})},s}())),O(i),e(t)});p("__e",function(e,t,i,r){O(),e(t,i,r)});p("diffed",function(e,t){O();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 l=s[a];l!==void 0&&!(a in r)&&(l.d(),s[a]=void 0)}else i.U=s={};for(var b in r){var I=s[b],M=r[b];I===void 0?(I=re(i,b,M,o),s[b]=I):I.o(M,o)}}}e(t)});function re(e,t,i,r){var o=t in e&&e.ownerSVGElement===void 0,s=v(i);return{o:function(a,l){s.value=a,r=l},d:g(function(){var a=s.value.value;r[t]!==a&&(r[t]=a,o?e[t]=a:a?e.setAttribute(t,a):e.removeAttribute(t))})}}p("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 l=a.__$u;l&&(a.__$u=void 0,l.d())}}e(t)});p("__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 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 oe(e){return L(function(){return v(e)},[])}const se=v({pending:!1,data:void 0}),ne=v(null);g(()=>{ne.value||(se.value={data:null,pending:!1})});const ae=v({checked:!0,setByUser:!1}),fe=v({pending:!1,data:void 0});g(()=>{var e;(e=fe.value.data)!=null&&e.isVirtual&&(ae.value={checked:!1,setByUser:!1})});const de={cartId:null,authenticated:!1},De=new Proxy(de,{set(e,t,i){return e[t]=i,!0},get(e,t){return e[t]}}),ue=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})):[],le=e=>e?e.filter(Boolean).filter(t=>(t==null?void 0:t.name)&&(t==null?void 0:t.value)):[],ce=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:ue(i.options),sortOrder:i.sort_order||void 0,validateRules:le(i.validate_rules)})):[],ve=e=>{if(e)return e.filter(t=>!!t).filter(t=>{const{two_letter_abbreviation:i,full_name_locale:r}=t;return!!i&&!!r}).map(t=>{const{two_letter_abbreviation:i,full_name_locale:r}=t;return{value:i,label:r}})},W=y(void 0);function Ae({children:e}){const[t,i]=x({});return N(()=>{Ee().then(r=>i({fields:r}))},[]),T(W.Provider,{value:t,children:e})}function Pe(){const e=S(W);if(e!==void 0)return e;throw new Error("useAddressFormFields must be used within an AddressFormFieldsProvider")}var he=(e=>(e.EMPTY="EMPTY",e.IN_PROGRESS="IN_PROGRESS",e.INIT="INIT",e.LOADING="LOADING",e.COMPLETE="COMPLETE",e))(he||{}),pe=(e=>(e[e.CART_UPDATED=0]="CART_UPDATED",e[e.ORDER_PLACED=1]="ORDER_PLACED",e[e.USER_AUTHENTICATED=2]="USER_AUTHENTICATED",e[e.USER_UNAUTHENTICATED=3]="USER_UNAUTHENTICATED",e[e.USER_SIGN_OUT=4]="USER_SIGN_OUT",e))(pe||{});const _e=(e,t)=>{const i=o=>o!==void 0?o===null||o!=null&&o.isEmpty?"EMPTY":"IN_PROGRESS":"INIT";let r=e;switch(e){case"INIT":t.type===0&&(r=i(t.payload));break;case"IN_PROGRESS":t.type===1&&(r="COMPLETE"),t.type===2&&(r="LOADING"),t.type===4&&(r="LOADING"),t.type===0&&(r=i(t.payload));break;case"EMPTY":case"LOADING":t.type===3&&(r="EMPTY"),t.type===0&&(r=i(t.payload))}return r},X=y(void 0),Ue=({children:e})=>{const[t,i]=K(_e,"INIT"),r={state:t,dispatch:i};return T(X.Provider,{value:r,children:e})};function Me(){const e=S(X);if(e!==void 0)return e;throw new Error("useCheckoutState must be used within a CheckoutStateProvider")}const Q=y(void 0);function Ge({children:e}){const[t,i]=x({});return N(()=>{Ie().then(r=>i({countries:r}))},[]),T(Q.Provider,{value:t,children:e})}function Le(){const e=S(Q);if(e!==void 0)return e;throw new Error("useCountries must be used within a CountriesProvider")}const Y=y({});function Fe({children:e,services:t}){return T(Y.Provider,{value:t,children:e})}function qe(){const e=S(Y);if(e!==void 0)return e;throw new Error("useServices must be used within a ServicesProvider")}const ye="US",u={defaultCountry:ye,countriesWithRequiredRegion:[],displayStateIfOptional:!1,countriesWithOptionalZipCode:[],isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1},j=y(void 0),$e=({children:e})=>{const[t,i]=x();return N(()=>{Oe().then(r=>{i(r)}).catch(()=>{console.error("Failed to fetch store config"),i(u)})},[]),T(j.Provider,{value:{config:t},children:e})};function ke(){const e=S(j);if(e!==void 0)return e;throw new Error("useStore must be used within a StoreProvider")}function Se(e){if(!e)return u;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}=e;return{defaultCountry:t||u.defaultCountry,countriesWithRequiredRegion:(i==null?void 0:i.split(","))||u.countriesWithRequiredRegion,displayStateIfOptional:r||u.displayStateIfOptional,countriesWithOptionalZipCode:(o==null?void 0:o.split(","))||u.countriesWithOptionalZipCode,isGuestCheckoutEnabled:s||u.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:a||u.isOnePageCheckoutEnabled}}const{setEndpoint:He,setFetchGraphQlHeader:Be,removeFetchGraphQlHeader:We,setFetchGraphQlHeaders:Xe,fetchGraphQl:P,getConfig:Qe}=new Z().getMethods(),Te=`
|
|
2
|
-
query fetchAddressFormFields {
|
|
3
|
-
attributesForm(formCode: "customer_register_address") {
|
|
4
|
-
items {
|
|
5
|
-
frontend_input
|
|
6
|
-
code
|
|
7
|
-
label
|
|
8
|
-
default_value
|
|
9
|
-
is_required
|
|
10
|
-
options {
|
|
11
|
-
label
|
|
12
|
-
value
|
|
13
|
-
is_default
|
|
14
|
-
}
|
|
15
|
-
... on CustomerAttributeMetadata {
|
|
16
|
-
multiline_count
|
|
17
|
-
sort_order
|
|
18
|
-
validate_rules {
|
|
19
|
-
name
|
|
20
|
-
value
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
errors {
|
|
25
|
-
message
|
|
26
|
-
type
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
`,U=e=>{if(!(!e||e.length===0))throw Error(e.map(t=>t.message).join(" "))},Ee=async()=>P(Te,{method:"GET",cache:"no-cache"}).then(({data:e,errors:t})=>(U(t),ce(e.attributesForm.items))).catch(w);var d=(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))(d||{}),ge=(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))(ge||{});const Ye=[{frontendInput:d.Text,code:"firstname",label:"First Name",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:10},{frontendInput:d.Text,code:"lastname",label:"Last Name",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:20},{frontendInput:d.Text,code:"company",label:"Company",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:30},{frontendInput:d.Multiline,code:"street",label:"Street Address",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:40},{frontendInput:d.Text,code:"city",label:"City",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:50},{frontendInput:d.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:d.Text,code:"region",label:"State/Province",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:70},{frontendInput:d.Hidden,code:"region_id",label:"State/Province",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:80},{frontendInput:d.Text,code:"postcode",label:"Zip/Postal Code",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:90},{frontendInput:d.Text,code:"telephone",label:"Phone Number",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:100},{frontendInput:d.Text,code:"vat_id",label:"VAT Number",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:110}],be=`
|
|
31
|
-
query getCountries {
|
|
32
|
-
countries {
|
|
33
|
-
two_letter_abbreviation
|
|
34
|
-
full_name_locale
|
|
35
|
-
}
|
|
36
|
-
}`,Ie=async()=>P(be,{method:"GET",cache:"no-cache"}).then(({data:e,errors:t})=>(t&&U(t),ve(e.countries))).catch(w),Ce=`
|
|
37
|
-
query getStoreConfig {
|
|
38
|
-
storeConfig {
|
|
39
|
-
countries_with_required_region
|
|
40
|
-
default_country
|
|
41
|
-
display_state_if_optional
|
|
42
|
-
is_guest_checkout_enabled
|
|
43
|
-
is_one_page_checkout_enabled
|
|
44
|
-
locale
|
|
45
|
-
optional_zip_countries
|
|
46
|
-
store_code
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
`,Oe=async()=>P(Ce,{method:"GET",cache:"no-cache"}).then(({data:e,errors:t})=>(U(t),Se(e==null?void 0:e.storeConfig))).catch(w);export{Ae as A,Le as B,Ge as C,qe as D,Fe as S,ge as V,Be as a,Xe as b,Ee as c,Ye as d,Ie as e,P as f,Qe as g,Oe as h,De as i,ae as j,se as k,fe as l,ne as m,w as n,U as o,$e as p,Ue as q,We as r,He as s,Me as t,Pe as u,pe as v,he as w,v as x,ke as y,d as z};
|
package/context/store.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { StoreConfig } from '../data/models';
|
|
2
|
-
import { FunctionComponent } from 'preact';
|
|
3
|
-
|
|
4
|
-
export declare const DEFAULT_COUNTRY = "US";
|
|
5
|
-
export declare const STORE_CONFIG_DEFAULTS: StoreConfig;
|
|
6
|
-
interface ContextData {
|
|
7
|
-
config?: StoreConfig;
|
|
8
|
-
}
|
|
9
|
-
export declare const StoreProvider: FunctionComponent;
|
|
10
|
-
export declare function useStore(): ContextData;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=store.d.ts.map
|