@dropins/storefront-checkout 0.1.0-alpha49 → 0.1.0-alpha50

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.
Files changed (151) hide show
  1. package/api/errors/errors.d.ts +3 -0
  2. package/api/estimateShippingMethods/estimateShippingMethods.d.ts +1 -1
  3. package/api/estimateShippingMethods/graphql/estimateShippingMethods.graphql.d.ts +16 -16
  4. package/api/getCart/graphql/getCart.graphql.d.ts +16 -16
  5. package/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts +16 -16
  6. package/api/index.d.ts +0 -3
  7. package/api/initialize/initialize.d.ts +6 -1
  8. package/api/initializeCheckout/initializeCheckout.d.ts +3 -17
  9. package/api/setBillingAddress/graphql/setBillingAddress.graphql.d.ts +15 -15
  10. package/api/setBillingAddress/setBillingAddress.d.ts +2 -11
  11. package/api/setShippingAddress/graphql/setShippingAddress.graphql.d.ts +15 -15
  12. package/api/setShippingAddress/setShippingAddress.d.ts +3 -45
  13. package/api/utils/dispatchApiCall.d.ts +0 -16
  14. package/api.js +37 -1
  15. package/chunks/Heading.js +1 -0
  16. package/chunks/classes.js +1 -0
  17. package/chunks/fetch-graphql.js +10 -0
  18. package/chunks/getCart.graphql.js +7 -4
  19. package/chunks/getCustomer.js +2 -2
  20. package/chunks/placeOrder2.js +131 -0
  21. package/chunks/resetCustomer.js +1 -36
  22. package/chunks/setBillingAddress.js +5 -7
  23. package/chunks/setGuestEmailOnCart.js +3 -3
  24. package/chunks/setPaymentMethod.js +2 -2
  25. package/chunks/setShippingMethods.js +2 -2
  26. package/chunks/store-config.js +1 -0
  27. package/chunks/withConditionalRendering.js +1 -1
  28. package/components/BillToShippingAddress/BillToShippingAddress.d.ts +3 -3
  29. package/components/LoginForm/Email.d.ts +8 -8
  30. package/components/LoginForm/LoginForm.d.ts +14 -10
  31. package/components/LoginForm/SignIn.d.ts +3 -4
  32. package/components/LoginForm/SignOut.d.ts +3 -3
  33. package/components/PaymentMethods/PaymentMethods.d.ts +4 -3
  34. package/components/index.d.ts +0 -2
  35. package/containers/BillToShippingAddress/BillToShippingAddress.d.ts +18 -6
  36. package/containers/BillToShippingAddress/index.d.ts +15 -16
  37. package/containers/BillToShippingAddress.js +1 -1
  38. package/containers/ErrorBanner/ErrorBanner.d.ts +2 -2
  39. package/containers/ErrorBanner.js +1 -1
  40. package/containers/EstimateShipping.js +1 -1
  41. package/containers/LoginForm/LoginForm.d.ts +2 -3
  42. package/containers/LoginForm/index.d.ts +15 -16
  43. package/containers/LoginForm.js +1 -1
  44. package/containers/MergedCartBanner/MergedCartBanner.d.ts +2 -2
  45. package/containers/MergedCartBanner.js +1 -1
  46. package/containers/OutOfStock.js +1 -1
  47. package/containers/PaymentMethods.js +1 -1
  48. package/containers/PlaceOrder/PlaceOrder.d.ts +1 -5
  49. package/containers/PlaceOrder.js +1 -1
  50. package/containers/ServerError.js +1 -1
  51. package/containers/ShippingMethods/hooks/useShippingEstimateEventEmitter.d.ts +15 -15
  52. package/containers/ShippingMethods.js +1 -1
  53. package/containers/index.d.ts +0 -2
  54. package/data/models/address.d.ts +11 -15
  55. package/data/models/api.d.ts +29 -0
  56. package/data/models/cart.d.ts +9 -5
  57. package/data/models/customer.d.ts +3 -14
  58. package/data/models/index.d.ts +19 -17
  59. package/data/models/region.d.ts +15 -15
  60. package/data/models/store-config.d.ts +0 -3
  61. package/data/transforms/index.d.ts +16 -18
  62. package/data/transforms/transform-address.d.ts +7 -5
  63. package/hocs/index.d.ts +16 -15
  64. package/hooks/index.d.ts +16 -16
  65. package/hooks/useStableList/index.d.ts +2 -0
  66. package/hooks/useStableList/useStableList.d.ts +2 -0
  67. package/i18n/en_US.json.d.ts +0 -18
  68. package/lib/index.d.ts +16 -15
  69. package/lib/validation.d.ts +5 -0
  70. package/msw/fixtures/fragments/cart.d.ts +3 -0
  71. package/msw/fixtures/fragments/index.d.ts +15 -18
  72. package/msw/fixtures/queries/index.d.ts +0 -3
  73. package/package.json +1 -1
  74. package/render.js +4 -4
  75. package/signals/IsBillToShippingSignal.d.ts +16 -20
  76. package/signals/index.d.ts +0 -3
  77. package/utils/index.d.ts +0 -6
  78. package/utils/refetchEstimatedShippingMethods/refetchEstimatedShippingMethods.d.ts +1 -0
  79. package/__generated__/types.d.ts +0 -15365
  80. package/api/fetchAddressFormFields/fetchAddressFormFields.d.ts +0 -18
  81. package/api/fetchAddressFormFields/fixtures.d.ts +0 -5
  82. package/api/fetchAddressFormFields/graphql/fetchAddressFormFields.graphql.d.ts +0 -18
  83. package/api/fetchAddressFormFields/index.d.ts +0 -19
  84. package/api/getCountries/fixtures.d.ts +0 -6
  85. package/api/getCountries/getCountries.d.ts +0 -18
  86. package/api/getCountries/graphql/getCountries.graphql.d.ts +0 -18
  87. package/api/getCountries/index.d.ts +0 -18
  88. package/api/getRegions/fixtures.d.ts +0 -5
  89. package/api/getRegions/getRegions.d.ts +0 -5
  90. package/api/getRegions/graphql/getRegions.graphql.d.ts +0 -18
  91. package/api/getRegions/index.d.ts +0 -18
  92. package/chunks/BillToShippingAddress.js +0 -1
  93. package/chunks/ShippingMethods.js +0 -1
  94. package/chunks/fixtures.js +0 -15
  95. package/chunks/getMultilineValues.js +0 -43
  96. package/chunks/placeOrder.js +0 -131
  97. package/chunks/setShippingAddress.js +0 -16
  98. package/chunks/transform-shipping-methods.js +0 -1
  99. package/components/AddressForm/AddressForm.d.ts +0 -22
  100. package/components/AddressForm/constants.d.ts +0 -20
  101. package/components/AddressForm/index.d.ts +0 -23
  102. package/components/AddressForm/useAddressBackup.d.ts +0 -8
  103. package/components/AddressForm/useAddressForm.d.ts +0 -39
  104. package/components/AddressForm/useCheckoutAddressEventEmitter.d.ts +0 -10
  105. package/components/AddressForm/usePreselectedFields.d.ts +0 -9
  106. package/components/AddressForm/utils.d.ts +0 -13
  107. package/components/FieldsForm/FieldsForm.d.ts +0 -13
  108. package/components/FieldsForm/FieldsFormSkeleton.d.ts +0 -4
  109. package/components/FieldsForm/fieldFactory.d.ts +0 -9
  110. package/components/FieldsForm/fixtures.d.ts +0 -5
  111. package/components/FieldsForm/index.d.ts +0 -22
  112. package/components/FieldsForm/validation.d.ts +0 -18
  113. package/containers/BillToShippingAddress/constants.d.ts +0 -18
  114. package/containers/BillingForm/BillingForm.d.ts +0 -9
  115. package/containers/BillingForm/constants.d.ts +0 -18
  116. package/containers/BillingForm/index.d.ts +0 -20
  117. package/containers/BillingForm.d.ts +0 -3
  118. package/containers/BillingForm.js +0 -1
  119. package/containers/LoginForm/constants.d.ts +0 -18
  120. package/containers/ShippingForm/ShippingForm.d.ts +0 -12
  121. package/containers/ShippingForm/constants.d.ts +0 -18
  122. package/containers/ShippingForm/index.d.ts +0 -20
  123. package/containers/ShippingForm.d.ts +0 -3
  124. package/containers/ShippingForm.js +0 -1
  125. package/data/models/address-form-fields.d.ts +0 -52
  126. package/data/transforms/transform-address-form-fields.d.ts +0 -66
  127. package/data/transforms/transform-countries.d.ts +0 -5
  128. package/data/transforms/transform-regions.d.ts +0 -8
  129. package/hooks/useValidity/index.d.ts +0 -18
  130. package/hooks/useValidity/useValidity.d.ts +0 -35
  131. package/msw/fixtures/fragments/american-regions.d.ts +0 -4
  132. package/msw/fixtures/fragments/countries.d.ts +0 -4
  133. package/msw/fixtures/fragments/form-fields.d.ts +0 -4
  134. package/msw/fixtures/queries/fetch-address-form-fields.d.ts +0 -4
  135. package/msw/fixtures/queries/get-countries.d.ts +0 -4
  136. package/msw/fixtures/queries/get-regions.d.ts +0 -4
  137. package/signals/AddressFormFieldsSignal.d.ts +0 -7
  138. package/signals/CountryListSignal.d.ts +0 -7
  139. package/signals/RegionsSignal.d.ts +0 -12
  140. package/utils/autocompleteFieldCodes/autocompleteFieldCodes.d.ts +0 -34
  141. package/utils/autocompleteFieldCodes/index.d.ts +0 -18
  142. package/utils/getMultilineValues/getMultilineValues.d.ts +0 -19
  143. package/utils/getMultilineValues/index.d.ts +0 -18
  144. package/utils/parseRegionId/index.d.ts +0 -18
  145. package/utils/parseRegionId/parseRegionId.d.ts +0 -18
  146. package/utils/processFormFields/index.d.ts +0 -18
  147. package/utils/processFormFields/processFormFields.d.ts +0 -21
  148. package/utils/scrollToElement/index.d.ts +0 -18
  149. package/utils/scrollToElement/scrollToElement.d.ts +0 -18
  150. package/utils/validateForms/index.d.ts +0 -18
  151. package/utils/validateForms/validateForms.d.ts +0 -18
@@ -1,18 +0,0 @@
1
- /********************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * __________________
4
- *
5
- * Copyright 2024 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
- *******************************************************************/
17
- export declare const fetchAddressFormFields: () => Promise<import('../../data/models/address-form-fields').AddressFormField[] | undefined>;
18
- //# sourceMappingURL=fetchAddressFormFields.d.ts.map
@@ -1,5 +0,0 @@
1
- import { AddressFormField } from '../../data/models/address-form-fields';
2
-
3
- declare const defaultFormFields: AddressFormField[];
4
- export { defaultFormFields };
5
- //# sourceMappingURL=fixtures.d.ts.map
@@ -1,18 +0,0 @@
1
- /********************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * __________________
4
- *
5
- * Copyright 2024 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
- *******************************************************************/
17
- export declare const fetchAddressFormFieldsQuery = "\n query fetchAddressFormFields {\n attributesForm(formCode: \"customer_register_address\") {\n items {\n frontend_input\n code\n label\n default_value\n is_required\n options {\n label\n value\n is_default\n }\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n validate_rules {\n name\n value\n }\n }\n }\n errors {\n message\n type\n }\n }\n }\n";
18
- //# sourceMappingURL=fetchAddressFormFields.graphql.d.ts.map
@@ -1,19 +0,0 @@
1
- /********************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * __________________
4
- *
5
- * Copyright 2024 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
- *******************************************************************/
17
- export * from './fetchAddressFormFields';
18
- export * from './fixtures';
19
- //# sourceMappingURL=index.d.ts.map
@@ -1,6 +0,0 @@
1
- import { Country as CountryModel } from '../../data/models/country';
2
-
3
- export declare const europeanCountries: CountryModel[];
4
- export declare const americanCountries: CountryModel[];
5
- export declare const countries: CountryModel[];
6
- //# sourceMappingURL=fixtures.d.ts.map
@@ -1,18 +0,0 @@
1
- /********************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * __________________
4
- *
5
- * Copyright 2024 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
- *******************************************************************/
17
- export declare const getCountries: () => Promise<import('../../data/models/country').Country[] | undefined>;
18
- //# sourceMappingURL=getCountries.d.ts.map
@@ -1,18 +0,0 @@
1
- /********************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * __________________
4
- *
5
- * Copyright 2024 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
- *******************************************************************/
17
- export declare const getCountriesQuery = "\nquery getCountries {\n countries {\n two_letter_abbreviation\n full_name_locale\n }\n}";
18
- //# sourceMappingURL=getCountries.graphql.d.ts.map
@@ -1,18 +0,0 @@
1
- /********************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * __________________
4
- *
5
- * Copyright 2024 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
- *******************************************************************/
17
- export * from './getCountries';
18
- //# sourceMappingURL=index.d.ts.map
@@ -1,5 +0,0 @@
1
- import { Region as RegionModel } from '../../data/models/region';
2
-
3
- export declare const americanRegions: RegionModel[];
4
- export declare const frenchRegions: RegionModel[];
5
- //# sourceMappingURL=fixtures.d.ts.map
@@ -1,5 +0,0 @@
1
- import { Region as RegionModel } from '../../data/models/region';
2
- import { AddressFormType } from '../../data/models';
3
-
4
- export declare const getRegions: (countryCode: string, addressType: AddressFormType) => Promise<RegionModel[] | undefined>;
5
- //# sourceMappingURL=getRegions.d.ts.map
@@ -1,18 +0,0 @@
1
- /********************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * __________________
4
- *
5
- * Copyright 2024 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
- *******************************************************************/
17
- export declare const getRegionsQuery = "\nquery getRegions($countryCode: String!) {\n country(id: $countryCode) {\n id\n available_regions {\n id\n code\n name\n }\n }\n}";
18
- //# sourceMappingURL=getRegions.graphql.d.ts.map
@@ -1,18 +0,0 @@
1
- /********************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * __________________
4
- *
5
- * Copyright 2024 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
- *******************************************************************/
17
- export * from './getRegions';
18
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- import{jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/event-bus.js";import{m as p,q as f,o as k}from"./fixtures.js";import{s as S}from"./setBillingAddress.js";import{classes as b}from"@dropins/tools/lib.js";import{Checkbox as _,Skeleton as v,SkeletonRow as A}from"@dropins/tools/components.js";/* empty css */import{useText as B}from"@dropins/tools/i18n.js";import{w as C}from"./withConditionalRendering.js";import{useState as I,useEffect as g}from"@dropins/tools/preact-compat.js";const x=({className:n,isInitialized:s=!0,checked:i=!0,...t})=>{const e=B({title:"Checkout.BillToShippingAddress.title"});return s?o("div",{className:b(["checkout-bill-to-shipping-address",n]),children:o(_,{"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(y,{})},y=()=>o(v,{className:"bill-to-shipping-address__skeleton",children:o(A,{variant:"row",size:"small"})}),m="is_bill_to_shipping_address";function T(n,s,i){const t=n[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(n,s,i){return!s&&!i?!0:!s||!i?!1:n.every(t=>{const e=t.code;return T(s,i,e)})}const w=({isBillToShipping:n})=>{var d;const[s,i]=I(!1),t=k.value.data,e=f.value.data,h=(e==null?void 0:e.id)||"",l=!!e,a=e==null?void 0:e.billingAddress,r=(d=e==null?void 0:e.shippingAddresses)==null?void 0:d[0],c=!!r;return g(()=>{if(s)return;const u=localStorage.getItem(m);u&&(i(!0),n.value={checked:u==="true",setByUser:!1})},[s,n]),g(()=>{if(s||!t||!l)return;i(!0);const u=N(t,a,r);n.value={checked:a?u:n.value.checked,setByUser:!1}},[a,t,l,n,s,r]),{cartId:h,isInitialized:s,hasShippingAddress:c}},z=({children:n,...s})=>{const i=p.value.checked,{hasShippingAddress:t,isInitialized:e}=w({isBillToShipping:p});return o("div",{children:o(x,{...s,checked:i,isInitialized:e,onChange:l=>{const r=l.target.checked;if(p.value={checked:r,setByUser:!0},localStorage.setItem(m,r.toString()),!e||!r||!t)return;const c=new AbortController;return S({signal:c.signal,input:{same_as_shipping:!0}}).catch(d=>{console.error(d)}),()=>{c.abort()}},disabled:f.value.pending})})},V=C(z);export{V as B,m as a,N as c};
@@ -1 +0,0 @@
1
- import{jsx as m,Fragment as me,jsxs as te}from"@dropins/tools/preact-jsx-runtime.js";import{events as re}from"@dropins/tools/event-bus.js";import{A as x,x as y,q as ne,V as k,o as ge,y as fe,t as he,p as pe}from"./fixtures.js";import{b as X,a as p,A as N,e as Fe,D as O,g as ve,M as J,c as K}from"./getMultilineValues.js";import{classes as Y,getFormErrors as Ie}from"@dropins/tools/lib.js";import{useState as G,useCallback as P,useEffect as z,useRef as Ee,useMemo as Ae}from"@dropins/tools/preact-hooks.js";import{Text as Ce,useText as Se}from"@dropins/tools/i18n.js";import{Field as H,Input as se,Picker as be,Skeleton as $e,SkeletonRow as $}from"@dropins/tools/components.js";/* empty css *//* empty css */import{forwardRef as Me,useRef as Re,useImperativeHandle as Le,useState as U,useEffect as q}from"@dropins/tools/preact-compat.js";const Z={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 ae(e){return Object.keys(e).length===0&&e.constructor===Object}const we=e=>e.map(t=>{var n;const r=((n=t==null?void 0:t.id)==null?void 0:n.toString())||t.code;return{text:t.name,value:r}}),Ne=e=>e?e.map(t=>({text:t.label,value:t.value})):[];function ye({address:e,addressType:t,availableCountries:r,availableRegions:n,config:s,dismissError:o,errors:c,fields:u,onBlur:d,onChange:F,onInvalid:a,onSelection:h,setAddress:v}){const I=()=>{v(i=>({...i,[p.Region]:"",[p.RegionId]:""})),o(p.Region)},A=i=>{v(M=>({...M,[p.RegionId]:i}))};return u.map(i=>{var f;let M,g=i.frontendInput,b=h,R=F,L=i.isDisabled,D=i.isRequired,w=[],S;return g===x.Multiline?(S=X(i.code,e),M=X(i.code,c)):(S=e[i.code],M=c[i.code]||""),i.code===p.Country&&(w=Ne(r),t===N.SHIPPING&&(y.value.country=S,b=l=>{const E=l.target,{value:C}=E;C&&T({country_code:C}),h(l),I()})),i.code===p.RegionId&&t===N.SHIPPING&&(y.value.selectedRegionId=S),i.code===p.Region&&(t===y.value.addressType&&(L=y.value.pending),D=s.countriesWithRequiredRegion.includes(e==null?void 0:e.country_id),w=we(n),!D&&!s.displayStateIfOptional&&(g=x.Undefined),g=w.length>0?x.Select:x.Text,g===x.Select?t===N.SHIPPING?(y.value.selectedRegion=S,b=l=>{const C=l.target.value;T({country_code:y.value.country,region_id:C}),h(l),A(C)}):b=l=>{h(l);const C=l.target.value;A(C)}:g===x.Text&&t===N.SHIPPING&&(y.value.selectedRegion=S,R=l=>{const E=l.target,{value:C}=E;y.value.country&&T({country_code:y.value.country,region_name:C}),F(l)}),S=w.length>0?((f=w.find(l=>l.value===S))==null?void 0:f.value)||"":S),i.code===p.PostCode&&(D=!s.countriesWithOptionalZipCode.includes(e==null?void 0:e.country_id)),{...i,error:M,frontendInput:g,handleSelect:b,isDisabled:L,isRequired:D,onBlur:d,onChange:R,onInvalid:a,options:w,value:S}})}let Q;function T(e){var o;const t=ne.value.data,r=!!t,n=(o=t==null?void 0:t.shippingAddresses)==null?void 0:o[0],s=n==null?void 0:n.availableShippingMethods;r&&!s&&(clearTimeout(Q),Q=setTimeout(()=>{Fe({criteria:e})},O))}const V=({addressType:e,code:t,index:r})=>r?`${e}-${t}-${r}`:`${e}-${t}`,B=e=>`checkout-address-form__${e}`,ke=({addressType:e,element:t})=>{const{code:r,value:n,defaultValue:s}=t;return m("input",{className:B(r),id:V({addressType:e,code:r}),name:r,type:"hidden",value:n||s},r)},De=({addressType:e,element:t})=>{const{code:r,error:n,isDisabled:s,label:o,onBlur:c,onChange:u,onInvalid:d,validateRules:F,value:a}=t,h=oe(F);return m(H,{disabled:s,error:n,children:m(se,{"aria-label":o,autocomplete:Z[r]||"off",className:B(r),floatingLabel:`${o} ${t.isRequired?"*":""}`,id:V({addressType:e,code:r}),onBlur:c,onChange:u,onInvalid:d,placeholder:o,required:t.isRequired||!1,type:"text",name:r,value:a??void 0,...h})})},_e=({addressType:e,element:t})=>{const{code:r,error:n,isDisabled:s,isRequired:o,label:c,multilineCount:u,onBlur:d,onChange:F,onInvalid:a,validateRules:h,value:v}=t,I=u??0,A=oe(h);return m(me,{children:Array.from(Array(I).keys()).map(i=>m(H,{disabled:s,error:(n==null?void 0:n[i])||"",className:"dropin-field--multiline",children:m(se,{id:V({addressType:e,code:r,index:i}),className:B(r),floatingLabel:`${c} ${i!=0?i:""} ${o&&i===0?"*":""}`,autocomplete:i===0?Z[r]:"off","aria-label":c,placeholder:`${c} ${i!=0?i:""}`,type:"text",required:o&&i===0,onChange:F,onBlur:d,onInvalid:a,name:`${r}-${i}`,value:(v==null?void 0:v[i])||void 0,...A})},`${r}-${i}`))})},xe=({addressType:e,element:t})=>{const{code:r,error:n,handleSelect:s,isDisabled:o,isRequired:c,label:u,onBlur:d,onInvalid:F,options:a,value:h}=t,v=s?{handleSelect:s}:{};return m(H,{disabled:o,error:n,children:m(be,{id:V({addressType:e,code:r}),className:B(r),name:r,floatingLabel:`${u} ${c?"*":""}`,required:c,placeholder:u,"aria-label":u,options:a,value:h,autocomplete:Z[r]||"off",onBlur:d,onInvalid:F,...v},r)})},ze=({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 ke({addressType:e,element:t});case"TEXT":return De({addressType:e,element:t});case"MULTILINE":return _e({addressType:e,element:t});case"SELECT":return xe({addressType:e,element:t});default:return null}},oe=e=>e?e.reduce((t,r)=>{switch(r.name){case k.DateRangeMax:return{...t,max:r.value};case k.DateRangeMin:return{...t,min:r.value};case k.FileExtensions:return{...t,accept:r.value};case k.InputValidation:return{...t,pattern:Pe(r.value)};case k.MaxFileSize:case k.MaxImageHeight:case k.MaxImageWidth:return t;case k.MaxTextLength:return{...t,maxLength:r.value};case k.MinTextLength:return{...t,minLength:r.value};default:throw new Error(`Unknown rule: ${r.name}`)}},{}):{},_={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]*))?)$/},Pe=e=>{switch(e){case"alpha":return _.alpha.source;case"alphanumeric":return _.alphanumeric.source;case"alphanumeric-w-space":return _["alphanumeric-w-space"].source;case"alphanum-with-spaces":return _["alphanum-with-spaces"].source;case"url":return _.url.source;case"numeric":return _.numeric.source;case"email":return _.email.source;default:throw new Error(`Unknown validation type: ${e}`)}},Oe=e=>te($e,{...e,children:[m($,{variant:"heading",size:"medium"}),m($,{variant:"empty",size:"medium"}),m($,{size:"large"}),m($,{size:"large"}),m($,{size:"large",fullWidth:!0}),m($,{size:"large",fullWidth:!0,lines:3}),m($,{size:"large"}),m($,{size:"large"}),m($,{size:"large"}),m($,{size:"large"}),m($,{size:"large"}),m($,{size:"large"}),m($,{size:"large"})]}),Ve=({addressType:e,className:t,fields:r,formRef:n,headingId:s,name:o,...c})=>te("div",{...c,className:Y(["checkout-fields-form",t]),children:[m(at,{level:2,children:m(Ce,{id:s}),className:"checkout-fields-form__title"}),m("form",{name:o,ref:n,className:Y(["checkout-fields-form__form",t]),noValidate:!0,children:r.sort((u,d)=>!u.sortOrder||!d.sortOrder?u.code<d.code?-1:1:u.sortOrder-d.sortOrder).map(u=>ze({element:u,addressType:e}))})]}),Be=e=>{const t=new FormData(e),r=Object.fromEntries(t);return Object.entries(r).reduce((s,[o])=>{const c=e.elements[o];return c!=null&&c.validationMessage?{...s,[o]:c.validationMessage}:{...s}},{})};function Te(e){const[t,r]=U({});return q(()=>{e&&r(n=>({...n,country_id:e}))},[e]),{defaultValues:t}}function Ge({country:e,addressType:t}){const[r,n]=U([]);return q(()=>{if(!e){n([]);return}ve(e,t).then(s=>{n(s||[])}).catch(s=>{console.error(s)})},[n,e,t]),{availableRegions:r}}function He({autoFill:e,addressType:t,dismissError:r,loadAutoFill:n}){const[s,o]=U(!1),c=pe.value.data,u=!!c,d=ne.value.data,F=!!d;q(()=>{var M;if(!e||!F||s)return;let a,h=!1;a=st({addressType:t,cart:d}),!a&&u&&(a=nt({addressType:t,customer:c}),h=!0);const v=g=>g?g.split(K).length>1:!1;if(!a)return;o(!0);const I={[p.City]:a.city,[p.Company]:a.company||"",[p.Country]:a.country.value,[p.FirstName]:a.firstName,[p.LastName]:a.lastName,[p.PostCode]:a.postCode||"",[p.Telephone]:a.telephone||"",[p.Vat]:a.vatId||""},A=a.region;if(A){const g=(M=A==null?void 0:A.id)==null?void 0:M.toString();g?(I[p.Region]=g,I[p.RegionId]=g):I[p.Region]=A.code}a!=null&&a.street&&a.street.length>0&&a.street.forEach((g,b)=>{I[`${p.Street}${J}${b}`]=g}),((a==null?void 0:a.customAttributes)||[]).forEach(g=>{v(g.code)?g.value.split(K).forEach((R,L)=>{I[`${g.code}${J}${L}`]=R}):I[g.code]=g.value}),n({values:I,triggerAutoSave:h})},[t,e,d,c,s,F,u,n,r])}const vt=Me(({addressType:e,autoFill:t=!0,children:r,headingId:n,name:s,preselectedFields:o,saveAddressHandler:c,onCheckoutDataUpdate:u,...d},F)=>{const{data:a,pending:h}=ge.value,v=fe.value.data,I=v===void 0,A=a===void 0||h,i=he.value.data,M=i===void 0,{defaultValues:g}=Te(i==null?void 0:i.defaultCountry),b=rt({fields:a,preselectedFields:o}),R=Re(null),{address:L,errors:D,loadAutoFill:w,onBlur:S,dismissError:f,onChange:l,onInvalid:E,onSelection:C,setAddress:ie}=et({defaultValues:g,formRef:R,onCheckoutDataUpdate:u,preselection:b,saveAddressHandler:c,type:e}),{availableRegions:ce}=Ge({country:L.country_id,addressType:e});if(Le(F,()=>({triggerSaveAddress:le=>{if(!R.current)return;const de=Be(R.current);if(ae(de))return c({signal:le,address:L})}})),He({addressType:e,autoFill:t,loadAutoFill:w,dismissError:f}),A||I||M)return m(Oe,{"data-testid":`${e}-skeleton`});const ue=ye({address:L,addressType:e,availableCountries:v,availableRegions:ce,config:i,dismissError:f,errors:D,fields:a,onBlur:S,onChange:l,onInvalid:E,onSelection:C,setAddress:ie}),W={[N.SHIPPING]:"shipping",[N.BILLING]:"billing"};return m(Ve,{...d,name:s,addressType:e,className:`checkout-${W[e]}-form`,"data-testid":`${W[e]}-form`,fields:ue,formRef:R,headingId:n})}),Ue="DROPIN__CHECKOUT",j=e=>`${Ue}__${e.toUpperCase()}`,qe=(e,t)=>{window.localStorage.setItem(j(e),JSON.stringify(t))},Ze=e=>{const t=window.localStorage.getItem(j(e));return t?JSON.parse(t):null},je=e=>{window.localStorage.removeItem(j(e))};function We(e){const[t,r]=G(null),n=P(o=>setTimeout(()=>{qe(e,o)},O),[e]),s=P(()=>{je(e)},[e]);return z(()=>{const o=Ze(e);o&&r(o)},[e]),z(()=>{const o=re.on("checkout/order",()=>{s()});return()=>{o==null||o.off()}},[s]),{addressBackup:t,backupAddress:n,removeAddressBackup:s}}const Xe={[N.BILLING]:"billing",[N.SHIPPING]:"shipping"};function Je({address:e,type:t,isValid:r}){z(()=>{const n=setTimeout(()=>{re.emit("checkout/address",{type:Xe[t],address:e,isValid:r()})},O);return()=>{clearTimeout(n)}},[e,r,t])}const Ke={badInput:"aria-label",patternMismatch:"aria-label",rangeOverflow:"max",rangeUnderflow:"min",tooLong:"maxlength",tooShort:"minlength",typeMismatch:"aria-label",valueMissing:"aria-label"},Ye=["badInput","patternMismatch","rangeOverflow","rangeUnderflow","tooLong","tooShort","typeMismatch","valueMissing"],Qe=e=>{const[t,r]=G({}),n=P(c=>{const{name:u,validity:d,validationMessage:F}=c;let a=d.valid?"":F;Ye.forEach(h=>{if(!d[h])return;const v=e[h];if(!v)return;const I=Ke[h];a=v.replace("{field}",c.getAttribute(I)||"")}),r(h=>({...h,[u]:a}))},[e]);return{errors:t,dismissError:c=>{t[c]&&r(u=>{const{[c]:d,...F}=u;return F})},validateFormElement:n,resetErrors:()=>{r({})}}},ee=e=>{const t=e.current;if(!t)return!1;const r=Ie(t);return ae(r)},et=({defaultValues:e={},formRef:t,onCheckoutDataUpdate:r,preselection:n={},saveAddressHandler:s,type:o})=>{const c=Se({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"}),u=Ee(!1),[d,F]=G({});Je({address:d,type:o,isValid:P(()=>ee(t),[t])});const{addressBackup:a,backupAddress:h,removeAddressBackup:v}=We(o),{errors:I,validateFormElement:A,dismissError:i,resetErrors:M}=Qe(c),g=P(f=>{u.current=!1,s(f).then(()=>{v(),r==null||r()}).catch(l=>{u.current=!0,console.error("Saving address form failed:",l)})},[v,s,r]),b=(f,l)=>{F(E=>({...E,[f]:l})),u.current=!0},R=({values:f,triggerAutoSave:l=!1})=>{M(),F(E=>({...E,...f})),l&&(u.current=!0)},L=f=>{const l=f.target,{name:E,value:C}=l;b(E,C),A(l)},D=f=>{const l=f.target;A(l)},w=f=>{const l=f.target,{name:E,value:C}=l;b(E,C),A(l)},S=f=>{f.target.checkValidity()};return z(()=>{F(f=>({...e,...n,...a,...f}))},[e,n,a]),z(()=>{if(!u.current)return;const f=h(d);return()=>{clearTimeout(f)}},[d,h]),z(()=>{if(!u.current||!ee(t))return;const f=new AbortController,l=f.signal,E=setTimeout(()=>{g({signal:l,address:d})},O);return()=>{clearTimeout(E),f.abort()}},[d,t,g]),{address:d,errors:I,loadAutoFill:R,dismissError:i,onChange:L,onSelection:w,onBlur:S,onInvalid:D,setAddress:F}},tt={countryCode:p.Country,region:p.Region,postCode:p.PostCode};function rt({fields:e,preselectedFields:t}){return Ae(()=>!(!!e&&e.length>0)||!!!t?{}:Object.keys(t).reduce((s,o)=>{const c=tt[o];return!c||!e.some(d=>d.code===c)?s:{...s,[c]:t[o]}},{}),[e,t])}const nt=({addressType:e,customer:t})=>e===N.BILLING?t.defaultBillingAddress:t.defaultShippingAddress,st=({addressType:e,cart:t})=>{if(e===N.BILLING)return t.billingAddress;const r=t.shippingAddresses;if(!(!r||r.length===0))return r[0]},at=({className:e,children:t,level:r=2})=>{const n=r>=1&&r<=6?`h${r}`:"h2";return m(n,{className:e,children:t})};export{vt as A,at as H,_ as p};
@@ -1,15 +0,0 @@
1
- import{events as E}from"@dropins/tools/event-bus.js";import{signal as o,effect as I}from"@dropins/tools/signals.js";import{FetchGraphQL as M}from"@dropins/tools/fetch-graphql.js";class G extends Error{constructor(s){super(s.map(t=>t.message).join(" ")),this.name="FetchError"}}class p extends Error{constructor(s){super(s),this.name="InvalidArgument"}}class $ extends Error{constructor(s){super(s),this.name="UnexpectedError"}}class J extends p{constructor(){super("Cart ID is required")}}class K extends p{constructor(){super("Email is required")}}class V extends p{constructor(){super("Payment method code is required")}}class ee extends p{constructor(){super("Billing address is required")}}class se extends p{constructor(){super("Country Code is required")}}const C=[];function L(e){return new Promise((s,t)=>{C.push(e);const a=()=>{C[0]===e?e().then(s).catch(t).finally(()=>C.shift()):setTimeout(a,100)};a()})}const x=["sender_email","recipient_email"];function A(e){return e.filter(s=>!s.path||!x.some(t=>{var a;return((a=s.path)==null?void 0:a.at(-1))===t}))}const S=e=>{throw e instanceof DOMException&&e.name==="AbortError"||E.emit("error",{source:"checkout",type:"network",error:e}),e},R=o({data:void 0,pending:!1}),O=o({checked:!0,setByUser:!1}),_=o({pending:!1,data:void 0});I(()=>{var e;(e=_.value.data)!=null&&e.isVirtual&&(O.value={checked:!1,setByUser:!1})});I(()=>{_.value.pending||E.emit("checkout/data",_.value.data||null)});const U=o({data:void 0,pending:!1}),h=o({pending:!1,data:void 0});I(()=>{h.value.pending||h.value.data&&E.emit("checkout/customer",h.value.data)});const X=o({pending:!1,data:void 0}),q=o({pending:!1,data:void 0}),te=o(void 0),ae=o(),b=o({data:void 0,pending:!1}),k={cart:_,customer:h,estimateShippingMethods:X,regions:q,storeConfig:b,countryList:U,addressFormFields:R};function w(e,s){return s.split(".").reduce((t,a)=>t&&t[a]!==void 0?t[a]:void 0,e)}const N={cart:null,customer:null,estimateShippingMethods:null,regions:null,storeConfig:null,countryList:null,addressFormFields:null};async function P(e){const{defaultValueOnFail:s,query:t,options:a,path:l,signalType:c,type:T,transformer:f}=e,r=k[c],v=Symbol();N[c]=v,r.value={...r.value,pending:!0};try{const{data:g,errors:y}=await(T==="mutation"?L(()=>m(t,a).catch(S)):m(t,{method:"GET",cache:"no-cache",...a}).catch(S));if(y){const D=A(y);if(D.length>0)throw new G(D)}let u=w(g,l);if(u===void 0)throw new Error(`No data found at path: ${l}`);return f&&(u=f(u)),r.value={...r.value,data:u},setTimeout(()=>{r.value={...r.value,pending:N[c]===v?!1:r.value.pending}},0),u}catch(g){if(s)return r.value={pending:!1,data:s},s;if(g.name==="AbortError")return;throw r.value={...r.value,pending:!1},g}}const F={cartId:null,authenticated:!1},ie=new Proxy(F,{set(e,s,t){return e[s]=t,!0},get(e,s){return e[s]}}),H=`
2
- query getStoreConfig {
3
- storeConfig {
4
- countries_with_required_region
5
- default_country
6
- display_state_if_optional
7
- is_guest_checkout_enabled
8
- is_one_page_checkout_enabled
9
- locale
10
- optional_zip_countries
11
- shopping_cart_display_shipping
12
- store_code
13
- }
14
- }
15
- `;var d=(e=>(e.EXCLUDING_TAX="EXCLUDING_TAX",e.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",e.INCLUDING_TAX="INCLUDING_TAX",e))(d||{});const W="US",n={defaultCountry:W,countriesWithRequiredRegion:[],displayStateIfOptional:!1,countriesWithOptionalZipCode:[],isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1,shoppingCartDisplaySetting:{shipping:d.EXCLUDING_TAX}},re=async()=>await P({type:"query",query:H,options:{method:"GET",cache:"no-cache"},path:"storeConfig",signalType:"storeConfig",transformer:Q,defaultValueOnFail:n});function B(e){switch(e){case 1:return d.EXCLUDING_TAX;case 2:return d.INCLUDING_TAX;case 3:return d.INCLUDING_EXCLUDING_TAX;default:return d.EXCLUDING_TAX}}function Q(e){if(!e)return n;const{default_country:s,countries_with_required_region:t,display_state_if_optional:a,optional_zip_countries:l,is_guest_checkout_enabled:c,is_one_page_checkout_enabled:T,shopping_cart_display_shipping:f}=e;return{defaultCountry:s||n.defaultCountry,countriesWithRequiredRegion:(t==null?void 0:t.split(","))||n.countriesWithRequiredRegion,displayStateIfOptional:a||n.displayStateIfOptional,countriesWithOptionalZipCode:(l==null?void 0:l.split(","))||n.countriesWithOptionalZipCode,isGuestCheckoutEnabled:c||n.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:T||n.isOnePageCheckoutEnabled,shoppingCartDisplaySetting:{shipping:B(f)}}}const{setEndpoint:oe,setFetchGraphQlHeader:ne,removeFetchGraphQlHeader:le,setFetchGraphQlHeaders:de,fetchGraphQl:m,getConfig:ce}=new M().getMethods();var i=(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))(i||{}),Z=(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))(Z||{});const ue=[{frontendInput:i.Text,code:"firstname",label:"First Name",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:10},{frontendInput:i.Text,code:"lastname",label:"Last Name",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:20},{frontendInput:i.Text,code:"company",label:"Company",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:30},{frontendInput:i.Multiline,code:"street",label:"Street Address",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:40},{frontendInput:i.Text,code:"city",label:"City",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:50},{frontendInput:i.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:i.Text,code:"region",label:"State/Province",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:70},{frontendInput:i.Hidden,code:"region_id",label:"State/Province",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:80},{frontendInput:i.Text,code:"postcode",label:"Zip/Postal Code",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:90},{frontendInput:i.Text,code:"telephone",label:"Phone Number",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:100},{frontendInput:i.Text,code:"vat_id",label:"VAT Number",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:110}];export{i as A,W as D,G as F,p as I,J as M,n as S,d as T,$ as U,Z as V,K as a,V as b,ee as c,se as d,ne as e,de as f,m as g,ce as h,ue as i,re as j,ie as k,P as l,O as m,ae as n,R as o,h as p,_ as q,le as r,oe as s,b as t,S as u,te as v,X as w,q as x,U as y};
@@ -1,43 +0,0 @@
1
- import{k as _,M as y,d as h,l 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
- mutation estimateShippingMethods(
3
- $cartId: String!
4
- $address: EstimateAddressInput!
5
- ) {
6
- estimateShippingMethods(
7
- input: {
8
- cart_id: $cartId
9
- address: $address
10
- }
11
- ) {
12
- carrier_title
13
- carrier_code
14
- method_title
15
- method_code
16
- available
17
- amount {
18
- currency
19
- value
20
- }
21
- price_excl_tax {
22
- currency
23
- value
24
- }
25
- price_incl_tax {
26
- currency
27
- value
28
- }
29
- error_message
30
- }
31
- }
32
- `,M=t=>t?!!t.id&&!!t.code&&!!t.name:!1,S=t=>{if(t)return t.filter(M).map(e=>{const{id:a,code:n,name:i}=e;return{id:a,code:n,name:i}})};var f=(t=>(t.SHIPPING="shipping_addresses",t.BILLING="billing_address",t))(f||{}),v=(t=>(t.City="city",t.Company="company",t.Country="country_id",t.FirstName="firstname",t.LastName="lastname",t.PostCode="postcode",t.Region="region",t.RegionId="region_id",t.SaveInAddressBook="save_in_address_book",t.Street="street",t.Telephone="telephone",t.Vat="vat_id",t))(v||{});const 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})},d=`
33
- query getRegions($countryCode: String!) {
34
- country(id: $countryCode) {
35
- id
36
- available_regions {
37
- id
38
- code
39
- name
40
- }
41
- }
42
- }`,N=async(t,e)=>(l.value.addressType=e,g({type:"query",query:d,options:{variables:{countryCode:t}},path:"country.available_regions",signalType:"regions",transformer:S})),p="-",R=`
43
- `,E=2e3,w=(t,e)=>Object.keys(e).filter(a=>a.startsWith(t)).sort((a,n)=>parseInt(a.replace(`${t}${p}`,""),10)-parseInt(n.replace(`${t}${p}`,""),10)).map(a=>e[a]);export{f as A,E as D,p as M,v as a,w as b,R as c,L as e,N as g};
@@ -1,131 +0,0 @@
1
- import{k as T,M as w,g as A,u as k,F as D,U as L}from"./fixtures.js";import{events as f}from"@dropins/tools/event-bus.js";const R=n=>({id:T.cartId,totalQuantity:n.totalQuantity,possibleOnepageCheckout:!0,items:n.items.map(a=>{var t;return{canApplyMsrp:!0,formattedPrice:"",id:a.id,quantity:a.totalQuantity,product:{canonicalUrl:a.product.canonicalUrl||"",mainImageUrl:a.product.image||"",name:a.product.name,productId:0,productType:a.product.productType,sku:a.product.sku},prices:{price:{value:a.price.value,currency:a.price.currency}},configurableOptions:((t=a.selectedOptions)==null?void 0:t.map(i=>({optionLabel:i.label,valueLabel:i.value})))||[]}})}),V=n=>{var i,c,l;const a=n.coupons[0],t=(i=n.payments)==null?void 0:i[0];return{appliedCouponCode:(a==null?void 0:a.code)||"",email:n.email,grandTotal:n.total,orderId:n.number,orderType:"checkout",otherTax:0,salesTax:n.totalTax,shipping:{shippingMethod:((c=n.shipping)==null?void 0:c.code)||"",shippingAmount:((l=n.shipping)==null?void 0:l.amount)||0},subtotalExcludingTax:n.subtotal,subtotalIncludingTax:0,payments:t?[{paymentMethodCode:(t==null?void 0:t.code)||"",paymentMethodName:(t==null?void 0:t.name)||"",total:n.total}]:[]}},q=n=>n||0,Q=n=>{var a;return{canonicalUrl:(n==null?void 0:n.canonical_url)||"",id:(n==null?void 0:n.uid)||"",name:(n==null?void 0:n.name)||"",sku:(n==null?void 0:n.sku)||"",image:((a=n==null?void 0:n.image)==null?void 0:a.url)||"",productType:(n==null?void 0:n.__typename)||""}};function M(n){if(!n||!("selected_options"in n))return;const a={};for(const t of n.selected_options)a[t.label]=t.value;return a}const P=n=>n?n.map(a=>{var t,i,c,l,u,s,e,p,_,o,y,g,h,v;return{type:a==null?void 0:a.__typename,id:a==null?void 0:a.id,discounted:(a==null?void 0:a.product.price_range.maximum_price.regular_price.value)*(a==null?void 0:a.quantity_ordered)!==(a==null?void 0:a.product_sale_price.value)*(a==null?void 0:a.quantity_ordered),total:{value:(a==null?void 0:a.product_sale_price.value)*(a==null?void 0:a.quantity_ordered),currency:a==null?void 0:a.product_sale_price.currency},totalInclTax:{value:(a==null?void 0:a.product_sale_price.value)*(a==null?void 0:a.quantity_ordered),currency:a==null?void 0:a.product_sale_price.currency},price:{value:a==null?void 0:a.product_sale_price.value,currency:a==null?void 0:a.product_sale_price.currency},priceInclTax:{value:a==null?void 0:a.product_sale_price.value,currency:a==null?void 0:a.product_sale_price.currency},totalQuantity:q(a==null?void 0:a.quantity_ordered),regularPrice:{value:(c=(i=(t=a==null?void 0:a.product)==null?void 0:t.price_range)==null?void 0:i.maximum_price)==null?void 0:c.regular_price.value,currency:(s=(u=(l=a==null?void 0:a.product)==null?void 0:l.price_range)==null?void 0:u.maximum_price)==null?void 0:s.regular_price.currency},product:Q(a==null?void 0:a.product),thumbnail:{label:((p=(e=a==null?void 0:a.product)==null?void 0:e.thumbnail)==null?void 0:p.label)||"",url:((o=(_=a==null?void 0:a.product)==null?void 0:_.thumbnail)==null?void 0:o.url)||""},giftCard:(a==null?void 0:a.__typename)==="GiftCardOrderItem"?{senderName:((y=a.gift_card)==null?void 0:y.sender_name)||"",senderEmail:((g=a.gift_card)==null?void 0:g.sender_email)||"",recipientEmail:((h=a.gift_card)==null?void 0:h.recipient_email)||"",recipientName:((v=a.gift_card)==null?void 0:v.recipient_name)||""}:void 0,configurableOptions:M(a)}}):[];function S(n){return n!==null&&n.value!==void 0}const C=n=>n?{city:n.city,company:n.company||"",country:n.country_code||"",firstName:n.firstname,middleName:n.middlename||"",lastName:n.lastname,postCode:n.postcode||"",regionId:n.region_id||"",region:n.region||"",street:n.street.filter(a=>a!==null),telephone:n.telephone||"",customAttributes:n.custom_attributesV2.filter(S).map(a=>({code:a.code,value:a.value}))}:null,U=n=>{var u,s,e,p,_,o,y,g,h,v;const a=(u=n.payment_methods)==null?void 0:u[0],t=(a==null?void 0:a.type)??"",i=(a==null?void 0:a.name)??"",c=P(n.items),l=c.reduce((b,N)=>b+N.totalQuantity,0);return{status:n.status,isVirtual:n.is_virtual,coupons:((s=n==null?void 0:n.applied_coupons)==null?void 0:s.map(b=>({code:(b==null?void 0:b.code)??""})))||[],email:n.email??"",items:c,number:n.number,token:n.token,grandTotal:{value:((e=n.total)==null?void 0:e.grand_total.value)??0,currency:((p=n.total)==null?void 0:p.grand_total.currency)||""},totalQuantity:l,totalTax:{value:((_=n.total)==null?void 0:_.total_tax.value)??0,currency:((o=n.total)==null?void 0:o.total_tax.currency)||""},subtotal:{value:((y=n.total)==null?void 0:y.subtotal.value)??0,currency:((g=n.total)==null?void 0:g.subtotal.currency)||""},shipping:{amount:((h=n.total)==null?void 0:h.total_shipping.value)??0,currency:((v=n.total)==null?void 0:v.total_shipping.currency)||"",code:n.shipping_method??""},payments:[{code:t,name:i}],shippingAddress:C(n.shipping_address),billingAddress:C(n.billing_address)}},G=`
2
- mutation placeOrder($cartId: String!) {
3
- placeOrder(input: { cart_id: $cartId }) {
4
- errors {
5
- code
6
- message
7
- }
8
- orderV2 {
9
- number
10
- status
11
- token
12
- is_virtual
13
- applied_coupons {
14
- code
15
- }
16
- email
17
- id
18
- total {
19
- grand_total {
20
- currency
21
- value
22
- }
23
- subtotal {
24
- currency
25
- value
26
- }
27
- total_shipping {
28
- currency
29
- value
30
- }
31
- total_tax {
32
- currency
33
- value
34
- }
35
- }
36
- shipping_method
37
- payment_methods {
38
- name
39
- type
40
- }
41
- billing_address {
42
- firstname
43
- middlename
44
- lastname
45
- street
46
- city
47
- postcode
48
- telephone
49
- country_code
50
- region
51
- region_id
52
- company
53
- custom_attributesV2 {
54
- code
55
- ... on AttributeValue {
56
- value
57
- }
58
- }
59
- }
60
- shipping_address {
61
- firstname
62
- middlename
63
- lastname
64
- street
65
- city
66
- postcode
67
- telephone
68
- country_code
69
- region
70
- region_id
71
- company
72
- custom_attributesV2 {
73
- code
74
- ... on AttributeValue {
75
- value
76
- }
77
- }
78
- }
79
- items {
80
- __typename
81
- id
82
- discounts {
83
- amount {
84
- value
85
- }
86
- }
87
- product {
88
- __typename
89
- canonical_url
90
- image {
91
- url
92
- }
93
- thumbnail {
94
- label
95
- url
96
- }
97
- name
98
- sku
99
- uid
100
- price_range {
101
- maximum_price {
102
- regular_price {
103
- currency
104
- value
105
- }
106
- }
107
- }
108
- }
109
- selected_options {
110
- label
111
- value
112
- }
113
- product_sale_price {
114
- value
115
- currency
116
- }
117
- quantity_ordered
118
- ... on GiftCardOrderItem {
119
- gift_card {
120
- recipient_name
121
- recipient_email
122
- sender_name
123
- sender_email
124
- message
125
- }
126
- }
127
- }
128
- }
129
- }
130
- }
131
- `,x={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},F={PLACE_ORDER:"place-order"};function E(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function O(n,a){const t=E();t.push({[n]:null}),t.push({[n]:a})}function X(n,a){E().push(i=>{const c=i.getState?i.getState():{};i.push({event:n,eventInfo:{...c,...a}})})}function $(n){const a=R(n),t=V(n);console.debug({shoppingCartContext:a,orderContext:t}),O(x.SHOPPING_CART_CONTEXT,{...a}),O(x.ORDER_CONTEXT,{...t}),X(F.PLACE_ORDER)}function H(n){throw n.every(t=>{var i;return(i=t.extensions)==null?void 0:i.category})?new D(n):new L(n[0].message)}const B=async()=>{const n=T.cartId;if(!n)throw new w;const{data:a,errors:t}=await A(G,{variables:{cartId:n}}).catch(k);t&&H(t);const i=U(a.placeOrder.orderV2);return $(i),f.emit("checkout/order",i),f.emit("cart/reset",void 0),i};export{B as p};
@@ -1,16 +0,0 @@
1
- import{a as s,b as p,M as u,c as _}from"./getMultilineValues.js";import{k as g,M as I,l}from"./fixtures.js";import{C,t as h}from"./getCart.graphql.js";import"@dropins/tools/event-bus.js";const A=/^\d+$/,T=t=>{if(A.test(t))return parseInt(t,10)},m=`
2
- mutation setShippingAddress($cartId: String!, $address: CartAddressInput!, $pickup_location_code: String) {
3
- setShippingAddressesOnCart(
4
- input: {
5
- cart_id: $cartId,
6
- shipping_addresses: [{ address: $address, pickup_location_code: $pickup_location_code }]
7
- }
8
- ) {
9
- cart {
10
- id
11
- ...CheckoutData
12
- }
13
- }
14
- }
15
- ${C}
16
- `,y=["city","company","country_code","firstname","lastname","postcode","region","region_id","save_in_address_book","street","telephone","vat_id"],$=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],c=T(r);c?a.region_id=c:a.region=r;const d=Object.keys(t).filter(e=>!e.startsWith("street")).filter(e=>!y.includes(e)).filter(e=>e!=="country_id").map(e=>{const[n,i]=e.split(u);if(!i)return{attribute_code:n,value:t[e]};const o=p(n,t).join(_);return{attribute_code:n,value:o}}).filter((e,n,i)=>n===i.findIndex(o=>o.attribute_code===e.attribute_code));return d.length>0&&(a.custom_attributes=d),a},k=async({signal:t,...a})=>{const r=g.cartId;if(!r)throw new I;return await l({type:"mutation",query:m,options:{signal:t,variables:{cartId:r,...a}},path:"setShippingAddressesOnCart.cart",signalType:"cart",transformer:h})};export{y as S,$ as p,k as s};
@@ -1 +0,0 @@
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,22 +0,0 @@
1
- import { SaveAddressCommand } from '.';
2
- import { PreselectedAddressFields } from '../../containers';
3
- import { AddressFormType } from '../../data/models';
4
- import { cartSignal } from '../../signals';
5
- import { HTMLAttributes } from 'preact/compat';
6
-
7
- export interface AddressFormProps extends HTMLAttributes<HTMLDivElement> {
8
- addressType: AddressFormType;
9
- autoFill?: boolean;
10
- headingId: string;
11
- name: string;
12
- onCheckoutDataUpdate?: () => Promise<void>;
13
- preselectedFields?: PreselectedAddressFields;
14
- saveAddressHandler: (command: SaveAddressCommand) => Promise<typeof cartSignal.value.data>;
15
- }
16
- export type AddressFormHandle = {
17
- triggerSaveAddress: (signal: AbortSignal) => Promise<typeof cartSignal.value.data> | undefined;
18
- };
19
- export declare const AddressForm: import('preact').FunctionalComponent<import('preact/compat').PropsWithoutRef<AddressFormProps> & {
20
- ref?: import('preact').Ref<AddressFormHandle> | undefined;
21
- }>;
22
- //# sourceMappingURL=AddressForm.d.ts.map
@@ -1,20 +0,0 @@
1
- /********************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * __________________
4
- *
5
- * Copyright 2024 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
- *******************************************************************/
17
- export declare const MULTILINE_SUFFIX = "-";
18
- export declare const MULTILINE_CUSTOM_ATTR_SPLIT = "\n";
19
- export declare const DEBOUNCE_TIME = 2000;
20
- //# sourceMappingURL=constants.d.ts.map
@@ -1,23 +0,0 @@
1
- /********************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * __________________
4
- *
5
- * Copyright 2024 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
- *******************************************************************/
17
- export * from './AddressForm';
18
- export * from './constants';
19
- export * from './useAddressForm';
20
- export * from './usePreselectedFields';
21
- export * from './utils';
22
- export { AddressForm as default } from './AddressForm';
23
- //# sourceMappingURL=index.d.ts.map
@@ -1,8 +0,0 @@
1
- import { AddressFormType, AddressFormValues } from '../../data/models/address-form-fields';
2
-
3
- export declare function useAddressBackup(addressType: AddressFormType): {
4
- addressBackup: AddressFormValues | null;
5
- backupAddress: (address: AddressFormValues) => NodeJS.Timeout;
6
- removeAddressBackup: () => void;
7
- };
8
- //# sourceMappingURL=useAddressBackup.d.ts.map
@@ -1,39 +0,0 @@
1
- import { AddressFormErrors, AddressFormType, AddressFormValues } from '../../data/models';
2
- import { cartSignal } from '../../signals';
3
- import { RefObject } from 'preact';
4
-
5
- export type DefaultValues = {
6
- country_id?: string;
7
- };
8
- export type AddressFormState = {
9
- address: AddressFormValues;
10
- errors: AddressFormErrors;
11
- };
12
- export type SaveAddressCommand = {
13
- signal?: AbortSignal;
14
- address: AddressFormValues;
15
- };
16
- export type LoadAutoFillProps = {
17
- values: AddressFormValues;
18
- triggerAutoSave: boolean;
19
- };
20
- export type UseAddressFormProps = {
21
- defaultValues?: DefaultValues;
22
- formRef: RefObject<HTMLFormElement>;
23
- onCheckoutDataUpdate?: () => Promise<void>;
24
- preselection?: AddressFormValues;
25
- saveAddressHandler: (command: SaveAddressCommand) => Promise<typeof cartSignal.value.data>;
26
- type: AddressFormType;
27
- };
28
- export declare const useAddressForm: ({ defaultValues, formRef, onCheckoutDataUpdate, preselection, saveAddressHandler, type, }: UseAddressFormProps) => {
29
- address: AddressFormValues;
30
- errors: Record<string, string>;
31
- loadAutoFill: ({ values, triggerAutoSave, }: LoadAutoFillProps) => void;
32
- dismissError: (code: string) => void;
33
- onChange: (event: Event) => void;
34
- onSelection: (event: Event) => void;
35
- onBlur: (event: Event) => void;
36
- onInvalid: (event: Event) => void;
37
- setAddress: import('preact/hooks').Dispatch<import('preact/hooks').StateUpdater<AddressFormValues>>;
38
- };
39
- //# sourceMappingURL=useAddressForm.d.ts.map
@@ -1,10 +0,0 @@
1
- import { AddressFormType, AddressFormValues } from '../../data/models';
2
-
3
- type useCheckoutAddressEventEmitterProps = {
4
- address: AddressFormValues;
5
- type: AddressFormType;
6
- isValid: () => boolean;
7
- };
8
- declare function useCheckoutAddressEventEmitter({ address, type, isValid, }: useCheckoutAddressEventEmitterProps): void;
9
- export default useCheckoutAddressEventEmitter;
10
- //# sourceMappingURL=useCheckoutAddressEventEmitter.d.ts.map
@@ -1,9 +0,0 @@
1
- import { PreselectedAddressFields } from '../../containers';
2
- import { AddressFormField, AddressFormValues } from '../../data/models/address-form-fields';
3
-
4
- export type UsePreselectedFieldsProps = {
5
- fields?: AddressFormField[];
6
- preselectedFields?: PreselectedAddressFields;
7
- };
8
- export declare function usePreselectedFields({ fields, preselectedFields, }: UsePreselectedFieldsProps): AddressFormValues;
9
- //# sourceMappingURL=usePreselectedFields.d.ts.map
@@ -1,13 +0,0 @@
1
- import { AddressFormType } from '../../data/models';
2
- import { Cart } from '../../data/models/cart';
3
- import { Customer } from '../../data/models/customer';
4
-
5
- export declare const getCustomerAddress: ({ addressType, customer, }: {
6
- addressType: AddressFormType;
7
- customer: Customer;
8
- }) => import('../../data/models').CustomerAddress | undefined;
9
- export declare const getCartAddress: ({ addressType, cart, }: {
10
- addressType: AddressFormType;
11
- cart: Cart;
12
- }) => import('../../data/models/address').Address | undefined;
13
- //# sourceMappingURL=utils.d.ts.map