@dropins/storefront-checkout 0.1.0-alpha33 → 0.1.0-alpha35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__generated__/types.d.ts +16556 -0
- package/api/errors/errors.d.ts +27 -0
- package/api/errors/index.d.ts +2 -0
- package/api/estimateShippingMethods/estimateShippingMethods.d.ts +13 -0
- package/api/estimateShippingMethods/fixtures.d.ts +8 -0
- package/api/estimateShippingMethods/graphql/estimateShippingMethods.graphql.d.ts +2 -0
- package/api/estimateShippingMethods/graphql/index.d.ts +2 -0
- package/api/estimateShippingMethods/index.d.ts +2 -0
- package/api/fetch-graphql/fetch-graphql.d.ts +8 -0
- package/api/fetch-graphql/index.d.ts +2 -0
- package/api/fetchAddressFormFields/fetchAddressFormFields.d.ts +4 -0
- package/api/fetchAddressFormFields/fixtures.d.ts +5 -0
- package/api/fetchAddressFormFields/graphql/fetchAddressFormFields.graphql.d.ts +2 -0
- package/api/fetchAddressFormFields/index.d.ts +3 -0
- package/api/getCart/fixtures.d.ts +12 -0
- package/api/getCart/getCart.d.ts +2 -0
- package/api/getCart/graphql/getCart.graphql.d.ts +4 -0
- package/api/getCart/graphql/index.d.ts +2 -0
- package/api/getCart/index.d.ts +2 -0
- package/api/getCountries/fixtures.d.ts +6 -0
- package/api/getCountries/getCountries.d.ts +4 -0
- package/api/getCountries/graphql/getCountries.graphql.d.ts +2 -0
- package/api/getCountries/index.d.ts +2 -0
- package/api/getCustomer/getCustomer.d.ts +4 -0
- package/api/getCustomer/graphql/getCustomer.graphql.d.ts +2 -0
- package/api/getCustomer/graphql/index.d.ts +2 -0
- package/api/getCustomer/index.d.ts +2 -0
- package/api/getRegions/fixtures.d.ts +5 -0
- package/api/getRegions/getRegions.d.ts +5 -0
- package/api/getRegions/graphql/getRegions.graphql.d.ts +2 -0
- package/api/getRegions/index.d.ts +2 -0
- package/api/getStoreConfig/getStoreConfig.d.ts +4 -0
- package/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts +2 -0
- package/api/getStoreConfig/index.d.ts +2 -0
- package/api/index.d.ts +19 -0
- package/api/initialize/index.d.ts +2 -0
- package/api/initialize/initialize.d.ts +10 -0
- package/api/isEmailAvailable/graphql/isEmailAvailable.graphql.d.ts +2 -0
- package/api/isEmailAvailable/index.d.ts +2 -0
- package/api/isEmailAvailable/isEmailAvailable.d.ts +4 -0
- package/api/placeOrder/fixtures.d.ts +6 -0
- package/api/placeOrder/graphql/index.d.ts +2 -0
- package/api/placeOrder/graphql/placeOrder.graphql.d.ts +2 -0
- package/api/placeOrder/index.d.ts +2 -0
- package/api/placeOrder/placeOrder.d.ts +2 -0
- package/api/redirect/index.d.ts +2 -0
- package/api/redirect/redirect.d.ts +2 -0
- package/api/setBillingAddress/graphql/setBillingAddress.graphql.d.ts +2 -0
- package/api/setBillingAddress/index.d.ts +2 -0
- package/api/setBillingAddress/setBillingAddress.d.ts +13 -0
- package/api/setGuestEmailOnCart/graphql/setGuestEmailOnCart.graphql.d.ts +2 -0
- package/api/setGuestEmailOnCart/index.d.ts +2 -0
- package/api/setGuestEmailOnCart/setGuestEmailOnCart.d.ts +2 -0
- package/api/setPaymentMethod/graphql/setPaymentMethod.graphql.d.ts +2 -0
- package/api/setPaymentMethod/index.d.ts +2 -0
- package/api/setPaymentMethod/setPaymentMethod.d.ts +2 -0
- package/api/setShippingAddress/graphql/setShippingAddress.graphql.d.ts +2 -0
- package/api/setShippingAddress/index.d.ts +2 -0
- package/api/setShippingAddress/setShippingAddress.d.ts +30 -0
- package/api/setShippingMethods/graphql/setShippingMethodsOnCart.graphql.d.ts +2 -0
- package/api/setShippingMethods/index.d.ts +2 -0
- package/api/setShippingMethods/setShippingMethods.d.ts +2 -0
- package/api/utils/dispatchApiCall.d.ts +41 -0
- package/api/utils/enqueueRequest.d.ts +2 -0
- package/api/utils/filterControlledErrors.d.ts +18 -0
- package/api.d.ts +1 -0
- package/api.js +1 -2
- package/chunks/BillToShippingAddress2.js +1 -2
- package/chunks/BillingForm.js +1 -2
- package/chunks/ErrorBanner.js +1 -2
- package/chunks/LoginForm.js +1 -2
- package/chunks/MergedCartBanner.js +1 -0
- package/chunks/PlaceOrder.js +1 -2
- package/chunks/ShippingForm.js +1 -2
- package/chunks/ShippingMethods.js +1 -2
- package/chunks/ToggleButton.js +1 -2
- package/chunks/ToggleButton2.js +1 -0
- package/chunks/address-form-fields.js +43 -0
- package/chunks/constants.js +0 -1
- package/chunks/constants2.js +1 -2
- package/chunks/constants3.js +1 -2
- package/chunks/getCart.graphql.js +10 -173
- package/chunks/getStoreConfig.js +4 -14
- package/chunks/initialize.js +1 -2
- package/chunks/placeOrder2.js +57 -70
- package/chunks/setBillingAddress.js +3 -6
- package/chunks/setGuestEmailOnCart.js +4 -7
- package/chunks/setPaymentMethod.js +3 -6
- package/chunks/setShippingAddress.js +4 -7
- package/chunks/setShippingMethods.js +4 -7
- package/chunks/transform-shipping-methods.js +1 -2
- package/components/AddressForm/AddressForm.d.ts +21 -0
- package/components/AddressForm/constants.d.ts +4 -0
- package/components/AddressForm/index.d.ts +7 -0
- package/components/AddressForm/useAddressBackup.d.ts +8 -0
- package/components/AddressForm/useAddressForm.d.ts +38 -0
- package/components/AddressForm/useCheckoutAddressEventEmitter.d.ts +9 -0
- package/components/AddressForm/usePreselectedFields.d.ts +9 -0
- package/components/AddressForm/utils.d.ts +13 -0
- package/components/BillToShippingAddress/BillToShippingAddress.d.ts +8 -0
- package/components/BillToShippingAddress/BillToShippingAddressSkeleton.d.ts +4 -0
- package/components/BillToShippingAddress/index.d.ts +4 -0
- package/components/Checkout/Checkout.d.ts +25 -0
- package/components/Checkout/index.d.ts +3 -0
- package/components/EmptyCart/EmptyCart.d.ts +9 -0
- package/components/EmptyCart/index.d.ts +3 -0
- package/components/FieldsForm/FieldsForm.d.ts +13 -0
- package/components/FieldsForm/FieldsFormSkeleton.d.ts +4 -0
- package/components/FieldsForm/fieldFactory.d.ts +9 -0
- package/components/FieldsForm/fixtures.d.ts +5 -0
- package/components/FieldsForm/index.d.ts +6 -0
- package/components/FieldsForm/validation.d.ts +18 -0
- package/components/Heading/Heading.d.ts +8 -0
- package/components/Heading/index.d.ts +3 -0
- package/components/LoginForm/Email.d.ts +13 -0
- package/components/LoginForm/LoginForm.d.ts +17 -0
- package/components/LoginForm/LoginFormSkeleton.d.ts +4 -0
- package/components/LoginForm/SignIn.d.ts +9 -0
- package/components/LoginForm/SignOut.d.ts +8 -0
- package/components/LoginForm/index.d.ts +6 -0
- package/components/OutOfStock/OutOfStock.d.ts +9 -0
- package/components/OutOfStock/index.d.ts +3 -0
- package/components/OverlayLoader/OverlayLoader.d.ts +6 -0
- package/components/OverlayLoader/index.d.ts +2 -0
- package/components/PaymentMethods/PaymentMethods.d.ts +13 -0
- package/components/PaymentMethods/PaymentMethodsSkeleton.d.ts +4 -0
- package/components/PaymentMethods/index.d.ts +4 -0
- package/components/PlaceOrder/PlaceOrder.d.ts +9 -0
- package/components/PlaceOrder/PlaceOrderSkeleton.d.ts +4 -0
- package/components/PlaceOrder/index.d.ts +3 -0
- package/components/ServerError/ServerError.d.ts +10 -0
- package/components/ServerError/index.d.ts +3 -0
- package/components/ShippingMethods/ShippingMethods.d.ts +12 -0
- package/components/ShippingMethods/ShippingMethodsSkeleton.d.ts +4 -0
- package/components/ShippingMethods/index.d.ts +4 -0
- package/components/ToggleButton/ToggleButton.d.ts +14 -0
- package/components/ToggleButton/assets/icons/index.d.ts +2 -0
- package/components/ToggleButton/assets/images/index.d.ts +2 -0
- package/components/ToggleButton/index.d.ts +3 -0
- package/components/index.d.ts +15 -0
- package/containers/BillToShippingAddress/BillToShippingAddress.d.ts +10 -0
- package/containers/BillToShippingAddress/constants.d.ts +2 -0
- package/containers/BillToShippingAddress/index.d.ts +4 -0
- package/containers/BillToShippingAddress.d.ts +3 -0
- package/containers/BillToShippingAddress.js +1 -2
- package/containers/BillingForm/BillingForm.d.ts +7 -0
- package/containers/BillingForm/constants.d.ts +2 -0
- package/containers/BillingForm/index.d.ts +4 -0
- package/containers/BillingForm.d.ts +3 -0
- package/containers/BillingForm.js +1 -2
- package/containers/Checkout/Checkout.d.ts +35 -0
- package/containers/Checkout/constants.d.ts +2 -0
- package/containers/Checkout/index.d.ts +4 -0
- package/containers/Checkout.d.ts +3 -0
- package/containers/Checkout.js +1 -2
- package/containers/ErrorBanner/ErrorBanner.d.ts +5 -0
- package/containers/ErrorBanner/index.d.ts +3 -0
- package/containers/ErrorBanner.d.ts +3 -0
- package/containers/ErrorBanner.js +0 -1
- package/containers/LoginForm/LoginForm.d.ts +10 -0
- package/containers/LoginForm/constants.d.ts +2 -0
- package/containers/LoginForm/index.d.ts +4 -0
- package/containers/LoginForm.d.ts +3 -0
- package/containers/LoginForm.js +1 -2
- package/containers/MergedCartBanner/MergedCartBanner.d.ts +5 -0
- package/containers/MergedCartBanner/index.d.ts +3 -0
- package/containers/MergedCartBanner.d.ts +3 -0
- package/containers/MergedCartBanner.js +1 -0
- package/containers/PaymentMethods/PaymentMethods.d.ts +23 -0
- package/containers/PaymentMethods/defaultHandlers.d.ts +11 -0
- package/containers/PaymentMethods/index.d.ts +3 -0
- package/containers/PaymentMethods.d.ts +3 -0
- package/containers/PaymentMethods.js +1 -2
- package/containers/PlaceOrder/PlaceOrder.d.ts +9 -0
- package/containers/PlaceOrder/index.d.ts +3 -0
- package/containers/PlaceOrder.d.ts +3 -0
- package/containers/PlaceOrder.js +1 -2
- package/containers/ShippingForm/ShippingForm.d.ts +9 -0
- package/containers/ShippingForm/constants.d.ts +2 -0
- package/containers/ShippingForm/index.d.ts +4 -0
- package/containers/ShippingForm.d.ts +3 -0
- package/containers/ShippingForm.js +1 -2
- package/containers/ShippingMethods/ShippingMethods.d.ts +9 -0
- package/containers/ShippingMethods/hooks/useShippingEstimateEventEmitter.d.ts +3 -0
- package/containers/ShippingMethods/index.d.ts +3 -0
- package/containers/ShippingMethods.d.ts +3 -0
- package/containers/ShippingMethods.js +1 -2
- package/containers/index.d.ts +11 -0
- package/context/address-form-fields.d.ts +13 -0
- package/context/checkout.d.ts +44 -0
- package/context/countries.d.ts +13 -0
- package/context/index.d.ts +6 -0
- package/context/services.d.ts +13 -0
- package/context/store.d.ts +12 -0
- package/data/models/acdl.d.ts +99 -0
- package/data/models/address-form-fields.d.ts +52 -0
- package/data/models/address.d.ts +21 -0
- package/data/models/cart.d.ts +14 -0
- package/data/models/country.d.ts +5 -0
- package/data/models/custom-attribute.d.ts +5 -0
- package/data/models/customer.d.ts +25 -0
- package/data/models/email-availability.d.ts +2 -0
- package/data/models/index.d.ts +14 -0
- package/data/models/order.d.ts +46 -0
- package/data/models/payment-method.d.ts +5 -0
- package/data/models/price.d.ts +5 -0
- package/data/models/region.d.ts +6 -0
- package/data/models/shipping-estimate.d.ts +17 -0
- package/data/models/shipping-method.d.ts +19 -0
- package/data/models/store-config.d.ts +9 -0
- package/data/transforms/index.d.ts +12 -0
- package/data/transforms/transform-acdl.d.ts +6 -0
- package/data/transforms/transform-address-form-fields.d.ts +66 -0
- package/data/transforms/transform-address.d.ts +79 -0
- package/data/transforms/transform-cart.d.ts +7 -0
- package/data/transforms/transform-countries.d.ts +5 -0
- package/data/transforms/transform-customer.d.ts +14 -0
- package/data/transforms/transform-email-availability.d.ts +6 -0
- package/data/transforms/transform-order.d.ts +7 -0
- package/data/transforms/transform-payment-methods.d.ts +9 -0
- package/data/transforms/transform-regions.d.ts +8 -0
- package/data/transforms/transform-shipping-estimate.d.ts +5 -0
- package/data/transforms/transform-shipping-methods.d.ts +14 -0
- package/data/transforms/transform-store-config.d.ts +5 -0
- package/hooks/useAuthentication/index.d.ts +2 -0
- package/hooks/useAuthentication/useAuthentication.d.ts +2 -0
- package/hooks/useLockScroll/index.d.ts +2 -0
- package/hooks/useLockScroll/useLockScroll.d.ts +5 -0
- package/hooks/useValidity/index.d.ts +2 -0
- package/hooks/useValidity/useValidity.d.ts +19 -0
- package/i18n/en_US.json.d.ts +86 -0
- package/lib/acdl.d.ts +18 -0
- package/lib/fetch-error.d.ts +7 -0
- package/lib/index.d.ts +4 -0
- package/lib/localStorage.d.ts +10 -0
- package/lib/network-error.d.ts +6 -0
- package/lib/redirect.d.ts +2 -0
- package/lib/state.d.ts +7 -0
- package/msw/browser.d.ts +2 -0
- package/msw/fixtures/fragments/american-regions.d.ts +4 -0
- package/msw/fixtures/fragments/available-shipping-methods.d.ts +23 -0
- package/msw/fixtures/fragments/billing-address.d.ts +36 -0
- package/msw/fixtures/fragments/cart.d.ts +112 -0
- package/msw/fixtures/fragments/countries.d.ts +4 -0
- package/msw/fixtures/fragments/form-fields.d.ts +4 -0
- package/msw/fixtures/fragments/index.d.ts +8 -0
- package/msw/fixtures/fragments/shipping-address.d.ts +42 -0
- package/msw/fixtures/index.d.ts +4 -0
- package/msw/fixtures/mutations/estimate-shipping-methods.d.ts +4 -0
- package/msw/fixtures/mutations/index.d.ts +8 -0
- package/msw/fixtures/mutations/place-order.d.ts +4 -0
- package/msw/fixtures/mutations/set-billing-address.d.ts +5 -0
- package/msw/fixtures/mutations/set-guest-email.d.ts +4 -0
- package/msw/fixtures/mutations/set-payment-method.d.ts +4 -0
- package/msw/fixtures/mutations/set-shipping-address.d.ts +4 -0
- package/msw/fixtures/mutations/set-shipping-methods.d.ts +4 -0
- package/msw/fixtures/queries/fetch-address-form-fields.d.ts +4 -0
- package/msw/fixtures/queries/get-cart.d.ts +4 -0
- package/msw/fixtures/queries/get-countries.d.ts +4 -0
- package/msw/fixtures/queries/get-customer-cart-stock-status.d.ts +4 -0
- package/msw/fixtures/queries/get-customer.d.ts +5 -0
- package/msw/fixtures/queries/get-regions.d.ts +4 -0
- package/msw/fixtures/queries/get-stock-status.d.ts +4 -0
- package/msw/fixtures/queries/get-store-config.d.ts +4 -0
- package/msw/fixtures/queries/index.d.ts +10 -0
- package/msw/fixtures/queries/is-email-available.d.ts +4 -0
- package/msw/handlers.d.ts +4 -0
- package/msw/server.d.ts +2 -0
- package/package.json +1 -1
- package/render/Provider.d.ts +10 -0
- package/render/index.d.ts +2 -0
- package/render/render.d.ts +6 -0
- package/render.d.ts +1 -0
- package/render.js +3 -4
- package/services/backup.d.ts +17 -0
- package/services/index.d.ts +2 -0
- package/signals/AuthenticationSignal.d.ts +2 -0
- package/signals/CartSignal.d.ts +7 -0
- package/signals/CustomerSignal.d.ts +7 -0
- package/signals/EstimateShippingMethodsSignal.d.ts +7 -0
- package/signals/IsBillToShippingSignal.d.ts +6 -0
- package/signals/RegionsSignal.d.ts +12 -0
- package/signals/SelectedShippingMethodSignal.d.ts +4 -0
- package/signals/index.d.ts +8 -0
- package/tests/constants.d.ts +3 -0
- package/tests/index.d.ts +2 -0
- package/tests/integration/utils/index.d.ts +3 -0
- package/tests/integration/utils/setup.d.ts +5 -0
- package/tests/integration/utils/user-actions.d.ts +2 -0
- package/tests/mocks/svg.d.ts +4 -0
- package/tests/render.d.ts +4 -0
- package/tests/utils/expectError.d.ts +9 -0
- package/tests/utils/index.d.ts +3 -0
- package/tests/utils/mockEvents.d.ts +5 -0
- package/utils/autocompleteFieldCodes/autocompleteFieldCodes.d.ts +18 -0
- package/utils/autocompleteFieldCodes/index.d.ts +2 -0
- package/utils/getMultilineValues/getMultilineValues.d.ts +3 -0
- package/utils/getMultilineValues/index.d.ts +2 -0
- package/utils/index.d.ts +7 -0
- package/utils/isEmpty/index.d.ts +2 -0
- package/utils/isEmpty/isEmpty.d.ts +2 -0
- package/utils/isNullish/index.d.ts +2 -0
- package/utils/isNullish/isNullish.d.ts +2 -0
- package/utils/parseRegionId/index.d.ts +2 -0
- package/utils/parseRegionId/parseRegionId.d.ts +2 -0
- package/utils/processFormFields/index.d.ts +2 -0
- package/utils/processFormFields/processFormFields.d.ts +21 -0
- package/utils/refetchEstimatedShippingMethods/index.d.ts +2 -0
- package/utils/refetchEstimatedShippingMethods/refetchEstimatedShippingMethods.d.ts +4 -0
- package/utils/shippingMethods/index.d.ts +2 -0
- package/utils/shippingMethods/isEqual.d.ts +4 -0
- package/api.js.map +0 -1
- package/chunks/BillToShippingAddress2.js.map +0 -1
- package/chunks/BillingForm.js.map +0 -1
- package/chunks/CartSummary.js +0 -2
- package/chunks/CartSummary.js.map +0 -1
- package/chunks/ErrorBanner.js.map +0 -1
- package/chunks/LoginForm.js.map +0 -1
- package/chunks/OrderSummary.js +0 -2
- package/chunks/OrderSummary.js.map +0 -1
- package/chunks/PaymentMethods.js +0 -2
- package/chunks/PaymentMethods.js.map +0 -1
- package/chunks/PlaceOrder.js.map +0 -1
- package/chunks/SelectedShippingMethodSignal.js +0 -2
- package/chunks/SelectedShippingMethodSignal.js.map +0 -1
- package/chunks/ShippingForm.js.map +0 -1
- package/chunks/ShippingMethods.js.map +0 -1
- package/chunks/ToggleButton.js.map +0 -1
- package/chunks/cart-item.js +0 -2
- package/chunks/cart-item.js.map +0 -1
- package/chunks/constants.js.map +0 -1
- package/chunks/constants2.js.map +0 -1
- package/chunks/constants3.js.map +0 -1
- package/chunks/getCart.graphql.js.map +0 -1
- package/chunks/getMultilineValues.js +0 -44
- package/chunks/getMultilineValues.js.map +0 -1
- package/chunks/getStoreConfig.js.map +0 -1
- package/chunks/initialize.js.map +0 -1
- package/chunks/placeOrder2.js.map +0 -1
- package/chunks/setBillingAddress.js.map +0 -1
- package/chunks/setGuestEmailOnCart.js.map +0 -1
- package/chunks/setPaymentMethod.js.map +0 -1
- package/chunks/setShippingAddress.js.map +0 -1
- package/chunks/setShippingMethods.js.map +0 -1
- package/chunks/transform-shipping-methods.js.map +0 -1
- package/containers/BillToShippingAddress.js.map +0 -1
- package/containers/BillingForm.js.map +0 -1
- package/containers/CartSummary.js +0 -2
- package/containers/CartSummary.js.map +0 -1
- package/containers/Checkout.js.map +0 -1
- package/containers/ErrorBanner.js.map +0 -1
- package/containers/LoginForm.js.map +0 -1
- package/containers/OrderSummary.js +0 -2
- package/containers/OrderSummary.js.map +0 -1
- package/containers/PaymentMethods.js.map +0 -1
- package/containers/PlaceOrder.js.map +0 -1
- package/containers/ShippingForm.js.map +0 -1
- package/containers/ShippingMethods.js.map +0 -1
- package/render.js.map +0 -1
package/chunks/ShippingForm.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import"@dropins/tools/event-bus.js";import{
|
|
2
|
-
//# sourceMappingURL=ShippingForm.js.map
|
|
1
|
+
import"@dropins/tools/event-bus.js";import{j as o}from"./getStoreConfig.js";import{s as t}from"./setBillingAddress.js";import{s as a,p as d}from"./setShippingAddress.js";import{A as m}from"./ToggleButton.js";import"@dropins/tools/preact-hooks.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 B=({preselectedFields:i,...e})=>{const s=o.value.checked,p=l(r=>a({signal:r.signal,address:d(r.address)}).then(()=>{if(s)return t({input:{same_as_shipping:!0}})}),[s]);return g(m,{...e,addressType:n.SHIPPING,headingId:"Checkout.ShippingAddress.title",name:h,preselectedFields:i,saveAddressHandler:p})};export{B as S};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{e as
|
|
2
|
-
//# sourceMappingURL=ShippingMethods.js.map
|
|
1
|
+
import{e as B}from"./address-form-fields.js";import{x as O,l as N,y as P}from"./getStoreConfig.js";import{events as w}from"@dropins/tools/event-bus.js";import{g as L,r as D}from"./transform-shipping-methods.js";import{s as V}from"./setShippingMethods.js";import{classes as W}from"@dropins/tools/lib.js";import{H as Z}from"./ToggleButton.js";import{IllustratedMessage as $,Icon as q,ProgressSpinner as F,RadioButton as G,Price as J,Divider as K,Skeleton as Q,SkeletonRow as y}from"@dropins/tools/components.js";import{useState as I,useEffect as x}from"@dropins/tools/preact-hooks.js";/* empty css */import{jsx as t,jsxs as j,Fragment as U}from"@dropins/tools/preact-jsx-runtime.js";import*as a from"@dropins/tools/preact-compat.js";import{useCallback as X,useMemo as Y,useEffect as A}from"@dropins/tools/preact-compat.js";import{useText as ee}from"@dropins/tools/i18n.js";const v=O(void 0),te=e=>({countryCode:e.country_id,postCode:e.postcode||"",...e.region_id?{regionId:Number(e.region_id)}:{...e.region?{region:e.region}:{}}}),oe=e=>({carrierCode:e.carrier.code||"",methodCode:e.code||"",amount:e.amount,amountExclTax:e.amountExclTax,amountInclTax:e.amountInclTax}),ne=e=>a.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},a.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"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.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"}),a.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"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),ie=({className:e,isLoading:r=!1,onSelectionChange:i=()=>{},options:s,selection:o,...d})=>{const h=ee({Title:"Checkout.ShippingMethods.title",EmptyState:"Checkout.ShippingMethods.emptyState"});return s===void 0?t(re,{}):j("div",{...d,className:W(["checkout-shipping-methods",e]),children:[t(Z,{level:3,className:"checkout-shipping-methods__title",children:h.Title}),!r&&s.length===0&&t($,{icon:t(q,{source:ne}),message:t("p",{children:h.EmptyState})}),j("div",{className:W(["checkout-shipping-methods__content"]),children:[r&&t(F,{className:"checkout-shipping-methods__spinner"}),t("div",{className:W(["checkout-shipping-methods__options",["checkout-shipping-methods__options--loading",r]]),children:s.map(n=>t(G,{"data-testid":"shipping-method-radiobutton","aria-busy":r,id:n.value,name:"shipping-method",className:"checkout-shipping-methods__method",label:j(U,{children:[t(J,{amount:n.amount.value,currency:n.amount.currency})," ",t("span",{children:n.carrier.title})]}),description:n.title,value:n.value,checked:(o==null?void 0:o.value)===n.value,onChange:()=>i(n)},n.value))})]}),t(K,{variant:"primary"})]})},re=()=>j(Q,{"data-testid":"shipping-methods-skeleton",children:[t(y,{variant:"heading",size:"small"}),t(y,{variant:"empty",size:"small"}),t(y,{size:"medium",fullWidth:!0}),t(y,{size:"medium",fullWidth:!0})]}),b=(e,r)=>e.code===r.code&&e.carrier.code===r.carrier.code;function se(){var c;const[e,r]=I(),[i,s]=I();x(()=>{w.on("checkout/address",({address:M,type:S})=>{S==="shipping"&&r(M)})},[]),x(()=>{s(v.value)},[v.value]),x(()=>{L.value.pending?s(void 0):s(v.value)},[L.value.pending]);const{country_id:o,region_id:d,region:h,postcode:n}=e||{},l=!!e,f=N.value.data,k=!!((c=f==null?void 0:f.shippingAddresses)!=null&&c[0]);x(()=>{k||!i||!l||w.emit("shipping/estimate",{address:te({country_id:o,region_id:d,region:h,postcode:n}),shippingMethod:oe(i)})},[i,o,d,h,n,l,k])}function ce(e){const i=P().config,s=!i,o=N.value.data,d=N.value.pending,h=L.value.data,n=L.value.pending,l=v.value,f=o==null?void 0:o.id,k=o==null?void 0:o.shippingAddresses,c=k==null?void 0:k[0],M=!!c,S=c==null?void 0:c.availableShippingMethods,C=c==null?void 0:c.selectedShippingMethod,u=S||h,T=X(p=>{if(!M)return;const m={method_code:p.code,carrier_code:p.carrier.code};V([m]).catch(_=>{console.error("setting shipping methods on cart failed:",_)})},[M]),R=p=>{v.value=p},g=Y(()=>{if(!(u!=null&&u.length))return;const p=u[0],m=l||C;return m?u.some(E=>b(E,m))?m:p:u.find(H=>H.carrier.code===(e==null?void 0:e.carrierCode)&&H.code===(e==null?void 0:e.methodCode))||p},[l,C,u,e]);return A(()=>{g&&((!l||!b(g,l))&&(v.value=g),(!C||!b(g,C))&&T(g))},[g,l,C,T]),A(()=>{if(!f||S)return;const{country:p,selectedRegion:m,selectedRegionId:_}=D.value,E=p||(i==null?void 0:i.defaultCountry);E&&B({criteria:{country_code:E,region_name:m,region_id:_}}).catch(z=>{L.value={pending:!1,data:[]},console.error("shipping methods estimation failed:",z)})},[f,S,i]),{isLoading:d||s||n,options:u,selection:g,onSelectionChange:R}}const Ee=({preSelectedMethod:e,...r})=>{const{isLoading:i,options:s,selection:o,onSelectionChange:d}=ce(e);return se(),t(ie,{...r,className:"checkout-shipping-methods",isLoading:i,onSelectionChange:d,options:s,selection:o})};export{Ee as S};
|
package/chunks/ToggleButton.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{events as fe}from"@dropins/tools/event-bus.js";import{B as z,i as re,V as $,u as he,D as ge,m as Fe,l as pe,E as ve}from"./getStoreConfig.js";import{b as K,a as g,A as N,e as Ie,D as q,g as Ee,M as Q,c as ee}from"./getMultilineValues.js";import{r as L}from"./transform-shipping-methods.js";import{useState as U,useEffect as x,useCallback as P,useRef as ke,useMemo as Ae}from"@dropins/tools/preact-hooks.js";import{classes as B,getFormErrors as Ce,VComponent as w}from"@dropins/tools/lib.js";import{Text as ne,useText as be}from"@dropins/tools/i18n.js";import{Field as Z,Input as oe,Picker as Se,Skeleton as we,SkeletonRow as C,ProgressSpinner as Me}from"@dropins/tools/components.js";/* empty css */import{jsx as a,Fragment as V,jsxs as O}from"@dropins/tools/preact-jsx-runtime.js";import{forwardRef as Re,useRef as $e,useImperativeHandle as Le,useState as j,useEffect as X}from"@dropins/tools/preact-compat.js";const Y={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 ye=e=>e.map(t=>{var n;const r=((n=t==null?void 0:t.id)==null?void 0:n.toString())||t.code;return{text:t.name,value:r}}),De=e=>e?e.map(t=>({text:t.label,value:t.value})):[];function Ne({address:e,addressType:t,availableCountries:r,availableRegions:n,config:s,dismissError:c,errors:o,fields:d,onBlur:m,onChange:i,onInvalid:F,onSelection:I,setAddress:p}){const E=()=>{p(u=>({...u,[g.Region]:"",[g.RegionId]:""})),c(g.Region)},R=u=>{p(f=>({...f,[g.RegionId]:u}))};return d.map(u=>{var v;let f,k=u.frontendInput,A,y=u.isDisabled,D=u.isRequired,M=[],l;if(k===z.Multiline?(l=K(u.code,e),f=K(u.code,o)):(l=e[u.code],f=o[u.code]||""),u.code===g.Country&&(M=De(r),t===N.SHIPPING?(L.value.country=l,A=h=>{const b=h.target,{value:S}=b;S&&W({country_code:S}),I(h),E()}):A=I),u.code===g.RegionId&&t===N.SHIPPING&&(L.value.selectedRegionId=l),u.code===g.Region){if(t===L.value.addressType&&(y=L.value.pending),D=s.countriesWithRequiredRegion.includes(e==null?void 0:e.country_id),M=ye(n),!D&&!s.displayStateIfOptional&&(k=z.Undefined),k=M.length>0?z.Select:z.Text,k===z.Select)t===N.SHIPPING?(L.value.selectedRegion=l,A=h=>{const S=h.target.value;W({country_code:L.value.country,region_id:S}),I(h),R(S)}):A=h=>{I(h);const S=h.target.value;R(S)};else if(k===z.Text&&t===N.SHIPPING){L.value.selectedRegion=l;const h=i;i=b=>{const S=b.target,{value:H}=S;L.value.country&&W({country_code:L.value.country,region_name:H}),h(b)}}l=M.length>0?((v=M.find(h=>h.value===l))==null?void 0:v.value)||"":l}return u.code===g.PostCode&&(D=!s.countriesWithOptionalZipCode.includes(e==null?void 0:e.country_id)),{...u,error:f,frontendInput:k,handleSelect:A,isDisabled:y,isRequired:D,onBlur:m,onChange:i,onInvalid:F,options:M,value:l}})}let te;function W(e){var c;const t=re.value.data,r=!!t,n=(c=t==null?void 0:t.shippingAddresses)==null?void 0:c[0],s=n==null?void 0:n.availableShippingMethods;r&&!s&&(clearTimeout(te),te=setTimeout(()=>{Ie({cartId:t.id,criteria:e})},q))}const G=({addressType:e,code:t,index:r})=>r?`${e}-${t}-${r}`:`${e}-${t}`,T=e=>`checkout-address-form__${e}`,_e=({addressType:e,element:t})=>{const{code:r,value:n,defaultValue:s}=t;return a("input",{className:T(r),id:G({addressType:e,code:r}),name:r,type:"hidden",value:n||s},r)},xe=({addressType:e,element:t})=>{const{code:r,error:n,isDisabled:s,label:c,onBlur:o,onChange:d,onInvalid:m,validateRules:i,value:F}=t,I=se(i);return a(Z,{disabled:s,error:n,children:a(oe,{"aria-label":c,autocomplete:Y[r]||"off",className:T(r),floatingLabel:`${c} ${t.isRequired?"*":""}`,id:G({addressType:e,code:r}),onBlur:o,onChange:d,onInvalid:m,placeholder:c,required:t.isRequired||!1,type:"text",name:r,value:F??void 0,...I})})},ze=({addressType:e,element:t})=>{const{code:r,error:n,isDisabled:s,isRequired:c,label:o,multilineCount:d,onBlur:m,onChange:i,onInvalid:F,validateRules:I,value:p}=t,E=d??0,R=se(I);return a(V,{children:Array.from(Array(E).keys()).map(u=>a(Z,{disabled:s,error:(n==null?void 0:n[u])||"",className:"dropin-field--multiline",children:a(oe,{id:G({addressType:e,code:r,index:u}),className:T(r),floatingLabel:`${o} ${u!=0?u:""} ${c&&u===0?"*":""}`,autocomplete:u===0?Y[r]:"off","aria-label":o,placeholder:`${o} ${u!=0?u:""}`,type:"text",required:c&&u===0,onChange:i,onBlur:m,onInvalid:F,name:`${r}-${u}`,value:(p==null?void 0:p[u])||void 0,...R})},`${r}-${u}`))})},Pe=({addressType:e,element:t})=>{const{code:r,error:n,handleSelect:s,isDisabled:c,isRequired:o,label:d,onBlur:m,onInvalid:i,options:F,value:I}=t,p=s?{handleSelect:s}:{};return a(Z,{disabled:c,error:n,children:a(Se,{id:G({addressType:e,code:r}),className:T(r),name:r,floatingLabel:`${d} ${o?"*":""}`,required:o,placeholder:d,"aria-label":d,options:F,value:I,autocomplete:Y[r]||"off",onBlur:m,onInvalid:i,...p},r)})},Oe=({addressType:e,element:t})=>{switch(t.frontendInput){case"BOOLEAN":case"DATE":case"DATETIME":case"FILE":case"GALLERY":case"IMAGE":case"MEDIA_IMAGE":case"MULTISELECT":case"PRICE":case"TEXTAREA":case"UNDEFINED":case"WEIGHT":return null;case"HIDDEN":return _e({addressType:e,element:t});case"TEXT":return xe({addressType:e,element:t});case"MULTILINE":return ze({addressType:e,element:t});case"SELECT":return Pe({addressType:e,element:t});default:return null}},se=e=>e?e.reduce((t,r)=>{switch(r.name){case $.DateRangeMax:return{...t,max:r.value};case $.DateRangeMin:return{...t,min:r.value};case $.FileExtensions:return{...t,accept:r.value};case $.InputValidation:return{...t,pattern:Ve(r.value)};case $.MaxFileSize:case $.MaxImageHeight:case $.MaxImageWidth:return t;case $.MaxTextLength:return{...t,maxLength:r.value};case $.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]*))?)$/},Ve=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}`)}},Be=e=>O(we,{...e,children:[a(C,{variant:"heading",size:"medium"}),a(C,{variant:"empty",size:"medium"}),a(C,{size:"large"}),a(C,{size:"large"}),a(C,{size:"large",fullWidth:!0}),a(C,{size:"large",fullWidth:!0,lines:3}),a(C,{size:"large"}),a(C,{size:"large"}),a(C,{size:"large"}),a(C,{size:"large"}),a(C,{size:"large"}),a(C,{size:"large"}),a(C,{size:"large"})]}),Ue=({addressType:e,className:t,fields:r,formRef:n,headingId:s,name:c,...o})=>O("div",{...o,className:B(["checkout-fields-form",t]),children:[a(ue,{level:2,children:a(ne,{id:s}),className:"checkout-fields-form__title"}),a("form",{name:c,ref:n,className:B(["checkout-fields-form__form",t]),noValidate:!0,children:r.sort((d,m)=>!d.sortOrder||!m.sortOrder?d.code<m.code?-1:1:d.sortOrder-m.sortOrder).map(d=>Oe({element:d,addressType:e}))})]}),Ge=e=>{const t=new FormData(e),r=Object.fromEntries(t);return Object.entries(r).reduce((s,[c])=>{const o=e.elements[c];return o!=null&&o.validationMessage?{...s,[c]:o.validationMessage}:{...s}},{})};function Te(e){const[t,r]=j({});return X(()=>{e&&r(n=>({...n,country_id:e}))},[e]),{defaultValues:t}}function He({country:e,addressType:t}){const[r,n]=j([]);return X(()=>{if(!e){n([]);return}Ee(e,t).then(s=>{n(s||[])}).catch(s=>{console.error(s)})},[n,e,t]),{availableRegions:r}}function We({autoFill:e,addressType:t,loadAutoFill:r}){const[n,s]=j(!1),c=pe.value.data,o=!!c,d=re.value.data,m=!!d;X(()=>{var u;if(!e||!m||n)return;let i,F=!1;i=tt({addressType:t,cart:d}),!i&&o&&(i=et({addressType:t,customer:c}),F=!0);const I=f=>f?f.split(ee).length>1:!1;if(!i)return;s(!0);const p={[g.City]:i.city,[g.Company]:i.company||"",[g.Country]:i.country.value,[g.FirstName]:i.firstName,[g.LastName]:i.lastName,[g.PostCode]:i.postCode||"",[g.Telephone]:i.telephone||"",[g.Vat]:i.vatId||""},E=i.region;if(E){const f=(u=E==null?void 0:E.id)==null?void 0:u.toString();f?(p[g.Region]=f,p[g.RegionId]=f):p[g.Region]=E.code}i!=null&&i.street&&i.street.length>0&&i.street.forEach((f,k)=>{p[`${g.Street}${Q}${k}`]=f}),((i==null?void 0:i.customAttributes)||[]).forEach(f=>{I(f.code)?f.value.split(ee).forEach((A,y)=>{p[`${f.code}${Q}${y}`]=A}):p[f.code]=f.value}),r({values:p,triggerAutoSave:F})},[t,e,d,c,n,m,o,r])}const Et=Re(({addressType:e,autoFill:t=!0,children:r,headingId:n,name:s,preselectedFields:c,saveAddressHandler:o,...d},m)=>{const{fields:i}=he(),{countries:F}=ge(),I=F===void 0,p=i===void 0,{config:E}=Fe(),R=E===void 0,{defaultValues:u}=Te(E==null?void 0:E.defaultCountry),f=Qe({fields:i,preselectedFields:c}),k=$e(null),{address:A,errors:y,loadAutoFill:D,onBlur:M,dismissError:l,onChange:v,onInvalid:h,onSelection:b,setAddress:S}=Je({formRef:k,type:e,defaultValues:u,preselection:f,saveAddressHandler:o}),{availableRegions:H}=He({country:A.country_id,addressType:e});if(Le(m,()=>({triggerSaveAddress:de=>{if(!k.current)return;const me=Ge(k.current);if(ae(me))return o({signal:de,address:A})}})),We({addressType:e,autoFill:t,loadAutoFill:D}),p||I||R)return a(Be,{"data-testid":`${e}-skeleton`});const le=Ne({address:A,addressType:e,availableCountries:F,availableRegions:H,config:E,dismissError:l,errors:y,fields:i,onBlur:M,onChange:v,onInvalid:h,onSelection:b,setAddress:S}),J={[N.SHIPPING]:"shipping",[N.BILLING]:"billing"};return a(Ue,{...d,name:s,addressType:e,className:`checkout-${J[e]}-form`,"data-testid":`${J[e]}-form`,fields:le,formRef:k,headingId:n})});function qe(e){const{backupService:t}=ve(),[r,n]=U(null);x(()=>{const o=t.restore(e);o&&n(o)},[e,t]),x(()=>{const o=fe.on("checkout/order",()=>{t.remove(e)});return()=>{o==null||o.off()}},[e,t]);const s=P(o=>setTimeout(()=>{t.backup(e,o)},q),[e,t]),c=P(()=>{t.remove(e)},[e,t]);return{addressBackup:r,backup:s,removeBackup:c}}const Ze={badInput:"aria-label",patternMismatch:"aria-label",rangeOverflow:"max",rangeUnderflow:"min",tooLong:"maxlength",tooShort:"minlength",typeMismatch:"aria-label",valueMissing:"aria-label"},je=["badInput","patternMismatch","rangeOverflow","rangeUnderflow","tooLong","tooShort","typeMismatch","valueMissing"],Xe=e=>{const[t,r]=U({}),n=P(c=>{const{name:o,validity:d,validationMessage:m}=c;let i=d.valid?"":m;je.forEach(F=>{if(!d[F])return;const I=e[F];if(!I)return;const p=Ze[F];i=I.replace("{field}",c.getAttribute(p)||"")}),r(F=>({...F,[o]:i}))},[e]);return{errors:t,dismissError:c=>{t[c]&&r(o=>{const{[c]:d,...m}=o;return m})},validateFormElement:n}},Ye=e=>{const t=e.current;if(!t)return!1;const r=Ce(t);return ae(r)},Je=({formRef:e,type:t,defaultValues:r={},preselection:n={},saveAddressHandler:s})=>{const c=be({badInput:"Checkout.AddressForm.Validity.badInput",patternMismatch:"Checkout.AddressForm.Validity.patternMismatch",rangeUnderflow:"Checkout.AddressForm.Validity.rangeUnderflow",tooLong:"Checkout.AddressForm.Validity.tooLong",tooShort:"Checkout.AddressForm.Validity.tooShort",typeMismatch:"Checkout.AddressForm.Validity.typeMismatch",valueMissing:"Checkout.AddressForm.Validity.valueMissing"}),o=ke(!1),[d,m]=U({}),{addressBackup:i,backup:F,removeBackup:I}=qe(t),{errors:p,validateFormElement:E,dismissError:R}=Xe(c),u=P(l=>{o.current=!1,s(l).then(()=>{I()}).catch(v=>{o.current=!0,console.error("Saving address form failed:",v)})},[I,s]),f=(l,v)=>{m(h=>({...h,[l]:v})),o.current=!0},k=({values:l,triggerAutoSave:v=!1})=>{m(h=>({...h,...l})),v&&(o.current=!0)},A=l=>{const v=l.target,{name:h,value:b}=v;f(h,b),E(v)},y=l=>{const v=l.target;E(v)},D=l=>{const v=l.target,{name:h,value:b}=v;f(h,b),E(v)},M=l=>{l.target.checkValidity()};return x(()=>{m(l=>({...r,...n,...i,...l}))},[r,n,i]),x(()=>{if(!o.current)return;const l=F(d);return()=>{clearTimeout(l)}},[d,F]),x(()=>{if(!o.current||!Ye(e))return;const l=new AbortController,v=l.signal,h=setTimeout(()=>{u({signal:v,address:d})},q);return()=>{clearTimeout(h),l.abort()}},[d,e,u]),{address:d,errors:p,loadAutoFill:k,dismissError:R,onChange:A,onSelection:D,onBlur:M,onInvalid:y,setAddress:m}},Ke={countryCode:g.Country,region:g.Region,postCode:g.PostCode};function Qe({fields:e,preselectedFields:t}){return Ae(()=>!(!!e&&e.length>0)||!!!t?{}:Object.keys(t).reduce((s,c)=>{const o=Ke[c];return!o||!e.some(m=>m.code===o)?s:{...s,[o]:t[c]}},{}),[e,t])}const et=({addressType:e,customer:t})=>e===N.BILLING?t.defaultBillingAddress:t.defaultShippingAddress,tt=({addressType:e,cart:t})=>{if(e===N.BILLING)return t.billingAddress;const r=t.shippingAddresses;if(!(!r||r.length===0))return r[0]},rt=()=>{const e=()=>window.innerWidth>=1920?"xxlarge":window.innerWidth>=1366?"xlarge":window.innerWidth>=1024?"large":window.innerWidth>=768?"medium":"small",[t,r]=U(e());return x(()=>{let n;const s=()=>{n&&clearTimeout(n),n=setTimeout(()=>r(e()),50)};return window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s),n&&clearTimeout(n)}},[]),t},ie=({children:e,className:t})=>rt()==="small"?a(V,{children:e}):a("div",{className:t,children:e}),nt=({sections:e})=>a(ie,{className:"checkout__aside",children:O(V,{children:[a(w,{node:e.orderSummary}),a(w,{node:e.cartSummary})]})}),ot=({billingAddress:e,billToShippingAddress:t,login:r,paymentMethods:n,placeOrder:s,shippingAddress:c,shippingMethods:o})=>O(V,{children:[a(w,{node:r}),c&&a(w,{node:c}),t&&a(w,{node:t}),o&&a(w,{node:o}),a(w,{node:n}),a(w,{node:e}),a(w,{node:s})]}),at=({outOfStock:e,sections:t})=>a(ie,{className:"checkout__main",children:O(V,{children:[a(ue,{level:1,className:"checkout-title",children:a(ne,{id:"Checkout.title"})}),e&&a(w,{className:"checkout-outOfStock",node:e}),t&&a(ot,{...t})]})}),ce=({banner:e,children:t,className:r,isLoading:n=!1,...s})=>O("div",{"data-testid":"checkout",className:B(["checkout",r]),...s,children:[n&&a(it,{}),e&&a(w,{className:"checkout__banner",node:e}),a("div",{className:"checkout__content",children:t})]});ce.Main=at;ce.Aside=nt;const ue=({className:e,children:t,level:r=2})=>{const n=r>=1&&r<=6?`h${r}`:"h2";return a(n,{className:e,children:t})},st=()=>{const e=P(()=>{document.body.style.overflow="hidden"},[]),t=P(()=>{document.body.style.overflow=""},[]);return{lockScroll:e,unlockScroll:t}},it=({className:e})=>{const{lockScroll:t,unlockScroll:r}=st();return x(()=>(t(),r),[t,r]),a("div",{"data-testid":"checkout-overlay-loader",className:B(["checkout-overlay-loader",e]),children:a(Me,{})})};export{Et as A,ce as C,ue as H,_ as p,rt as u};
|
|
2
|
-
//# sourceMappingURL=ToggleButton.js.map
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"@dropins/tools/event-bus.js";import{l as L}from"./getStoreConfig.js";import{s as z}from"./setPaymentMethod.js";import{H as O}from"./ToggleButton.js";import"@dropins/tools/preact-hooks.js";import{classes as f,Slot as E}from"@dropins/tools/lib.js";import{Skeleton as U,SkeletonRow as v,IllustratedMessage as $,Icon as q,ProgressSpinner as Z,Divider as F,RadioButton as G}from"@dropins/tools/components.js";/* empty css */import{jsxs as y,jsx as e,Fragment as J}from"@dropins/tools/preact-jsx-runtime.js";import*as M from"@dropins/tools/preact-compat.js";import{useState as P,useCallback as x,useEffect as N}from"@dropins/tools/preact-compat.js";import{useText as K}from"@dropins/tools/i18n.js";const Q=t=>M.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},M.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),M.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),M.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),X=()=>y(U,{"data-testid":"payment-methods-skeleton",children:[e(v,{variant:"heading",size:"medium"}),e(v,{variant:"empty",size:"medium"}),e(v,{size:"xlarge",fullWidth:!0}),e(v,{size:"xlarge",fullWidth:!0})]}),Y=({code:t,isLoading:n,isSelected:d,onChange:s,title:o})=>e(te,{className:"checkout-payment-methods__method",label:o,name:"payment-method",value:t,selected:d,onChange:s,radioButtonProps:{"aria-busy":n}}),D=({className:t,paymentMethodContent:n,isLoading:d,onChange:s=()=>{},options:o,selection:u})=>{const l=K({Title:"Checkout.PaymentMethods.title",EmptyState:"Checkout.PaymentMethods.emptyState"});return o===void 0?e(X,{}):y("div",{className:f(["checkout-payment-methods",t]),children:[e(O,{level:2,className:"checkout-payment-methods__title",children:l.Title}),!d&&o.length===0&&e($,{icon:e(q,{source:Q}),message:e("p",{children:l.EmptyState})}),y("div",{className:f(["checkout-payment-methods__wrapper"]),children:[d&&e(Z,{className:"checkout-payment-methods__spinner"}),e("div",{className:f(["checkout-payment-methods__methods",["checkout-payment-methods--loading",d],["checkout-payment-methods--full-width",o.length%2!==0]]),children:o==null?void 0:o.map(m=>e(Y,{code:m.code,onChange:s,isSelected:m.code===u,title:m.title},m.code))}),n&&e("div",{className:"checkout-payment-methods__content",children:n})]}),e(F,{variant:"primary"})]})},T={free:{render:t=>{const n=document.createElement("div");n.innerText="",t.replaceHTML(n)}},checkmo:{render:t=>{const n=document.createElement("div");n.innerText="",t.replaceHTML(n)}}};function ee(t){var w;const{onPlaceOrder:n,handleServerError:d,paymentMethodsSlot:s,isShippingInfoRequired:o}=t,[u,l]=P(),[m,g]=P(),[h,_]=P(T),[C,I]=P(!0),{data:a}=L.value,W=(a==null?void 0:a.id)??"",H=!!a,b=!!((w=a==null?void 0:a.shippingAddresses)!=null&&w[0]),i=a==null?void 0:a.availablePaymentMethods,c=a==null?void 0:a.selectedPaymentMethod,k=x(async r=>{try{if(l(r),!b&&o||r===(c==null?void 0:c.code))return;await z(r)}catch(p){console.error("setting payment method failed:",p)}},[b,o,c]);N(()=>{H&&(c!=null&&c.code?(i==null?void 0:i.some(p=>p.code===c.code))?l(c.code):i!=null&&i.length?k(i[0].code):l(void 0):i[0]&&k(m||i[0].code))},[i,H,c,k,m]);const B=async r=>{await k(r),c!=null&&c.code||g(r)},V=x((r,p)=>{if(!r){console.warn("Payment method handler is ignored because it has no code");return}if(!p){console.warn("Payment method handler is ignored because it is empty");return}_(R=>({...R,[r]:p}))},[]),j=s?e(E,{name:"PaymentMethods",slot:s,context:{addPaymentMethodHandler:V,replaceHTML(r){this.replaceWith(r),I(!1)}}}):null,S=u?h[u]:null,A=S?e(E,{name:"PaymentMethodContent",slot:S.render,context:{cartId:W,onPlaceOrder:n,handleServerError:d,replaceHTML(r){this.replaceWith(r)}}},S):void 0;return N(()=>{!C&&h!=T&&console.warn("Payment method handlers you have added are ignored because the default content has been replaced")},[C,h]),{availablePaymentMethods:i,selectedPaymentMethod:u,onPaymentMethodChange:B,paymentMethodContent:A,mainSlotContent:j,isDefaultContentUsed:C}}const ue=t=>{const{onPlaceOrder:n,handleServerError:d,paymentMethodsSlot:s,isShippingInfoRequired:o=!0}=t,{availablePaymentMethods:u,selectedPaymentMethod:l,onPaymentMethodChange:m,paymentMethodContent:g,mainSlotContent:h,isDefaultContentUsed:_}=ee({onPlaceOrder:n,handleServerError:d,paymentMethodsSlot:s,isShippingInfoRequired:o});return y(J,{children:[h&&e(h.type,{ref:h.ref,...h.props}),_&&e(D,{options:u,selection:l,onChange:m,paymentMethodContent:g,isLoading:L.value.pending})]})},te=({label:t,name:n,value:d,icon:s,selected:o,onChange:u,className:l,children:m,radioButtonProps:g,...h})=>e("div",{className:f(["checkout-toggle-button",l,["checkout-toggle-button__selected",o]]),...h,children:y("label",{className:"checkout-toggle-button__actionButton",children:[e(G,{...g,label:"",name:n,value:d,checked:o,onChange:()=>u(d),"aria-label":t,className:f([l,"checkout-toggle-button__radioButton"])}),y("div",{className:"checkout-toggle-button__content",children:[s&&e(s.type,{...s==null?void 0:s.props,className:"checkout-toggle-button__icon"}),t]})]})});export{ue as P};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import{M as _,d as y,e as g,t as h,r as l}from"./transform-shipping-methods.js";import{i as m}from"./getStoreConfig.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}})},L=async t=>{const e=m.cartId,{criteria:a}=t||{},{country_code:n,region_id:i,region_name:r,zip:s}=a||{};if(!e)throw new _;if(!n)throw new y;const o=typeof i=="string"?parseInt(i,10):i,c=i||r?{...o&&{region_id:o},...r&&{region_code:r}}:void 0,u={country_code:n,...s&&{postcode:s},...c&&{region:c}};return await g({type:"mutation",query:I,options:{variables:{cartId:e,address:u}},path:"estimateShippingMethods",signalType:"estimateShippingMethods",transformer:h})},f=`
|
|
33
|
+
query getRegions($countryCode: String!) {
|
|
34
|
+
country(id: $countryCode) {
|
|
35
|
+
id
|
|
36
|
+
available_regions {
|
|
37
|
+
id
|
|
38
|
+
code
|
|
39
|
+
name
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}`,N=async(t,e)=>(l.value.addressType=e,g({type:"query",query:f,options:{variables:{countryCode:t}},path:"country.available_regions",signalType:"regions",transformer:S})),p="-",R=`
|
|
43
|
+
`,E=2e3,w=(t,e)=>Object.keys(e).filter(a=>a.startsWith(t)).sort((a,n)=>parseInt(a.replace(`${t}${p}`,""),10)-parseInt(n.replace(`${t}${p}`,""),10)).map(a=>e[a]);var v=(t=>(t.SHIPPING="shipping_addresses",t.BILLING="billing_address",t))(v||{}),d=(t=>(t.City="city",t.Company="company",t.Country="country_id",t.FirstName="firstname",t.LastName="lastname",t.PostCode="postcode",t.Region="region",t.RegionId="region_id",t.SaveInAddressBook="save_in_address_book",t.Street="street",t.Telephone="telephone",t.Vat="vat_id",t))(d||{});export{v as A,E as D,p as M,d as a,w as b,R as c,L as e,N as g};
|
package/chunks/constants.js
CHANGED
package/chunks/constants2.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
//# sourceMappingURL=constants2.js.map
|
|
1
|
+
const s="billing_address";export{s as B};
|
package/chunks/constants3.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
//# sourceMappingURL=constants3.js.map
|
|
1
|
+
const o="login-form";export{o as L};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import{t as
|
|
2
|
-
fragment
|
|
1
|
+
import{t as a,f 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
|
+
fragment CheckoutData on Cart {
|
|
3
3
|
is_virtual
|
|
4
4
|
email
|
|
5
|
+
total_quantity
|
|
5
6
|
billing_address {
|
|
6
7
|
city
|
|
7
8
|
country {
|
|
@@ -90,185 +91,21 @@ import{t as d,g as p}from"./transform-shipping-methods.js";import{P as m}from"./
|
|
|
90
91
|
code
|
|
91
92
|
title
|
|
92
93
|
}
|
|
93
|
-
applied_coupons {
|
|
94
|
-
code
|
|
95
|
-
}
|
|
96
|
-
prices {
|
|
97
|
-
grand_total {
|
|
98
|
-
value
|
|
99
|
-
currency
|
|
100
|
-
}
|
|
101
|
-
subtotal_excluding_tax {
|
|
102
|
-
value
|
|
103
|
-
currency
|
|
104
|
-
}
|
|
105
|
-
subtotal_including_tax {
|
|
106
|
-
value
|
|
107
|
-
currency
|
|
108
|
-
}
|
|
109
|
-
applied_taxes {
|
|
110
|
-
label
|
|
111
|
-
amount {
|
|
112
|
-
currency
|
|
113
|
-
value
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
`,_=`
|
|
119
|
-
fragment CartSummaryItems on Cart {
|
|
120
|
-
total_quantity
|
|
121
|
-
itemsV2(sort: { field: CREATED_AT, order: DESC }) {
|
|
122
|
-
total_count
|
|
123
|
-
items {
|
|
124
|
-
__typename
|
|
125
|
-
uid
|
|
126
|
-
product {
|
|
127
|
-
__typename
|
|
128
|
-
uid
|
|
129
|
-
name
|
|
130
|
-
sku
|
|
131
|
-
url_key
|
|
132
|
-
thumbnail {
|
|
133
|
-
url
|
|
134
|
-
label
|
|
135
|
-
}
|
|
136
|
-
small_image {
|
|
137
|
-
url
|
|
138
|
-
}
|
|
139
|
-
price_range {
|
|
140
|
-
maximum_price {
|
|
141
|
-
regular_price {
|
|
142
|
-
currency
|
|
143
|
-
value
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
stock_status
|
|
148
|
-
only_x_left_in_stock
|
|
149
|
-
}
|
|
150
|
-
prices {
|
|
151
|
-
fixed_product_taxes {
|
|
152
|
-
amount {
|
|
153
|
-
currency
|
|
154
|
-
value
|
|
155
|
-
}
|
|
156
|
-
label
|
|
157
|
-
}
|
|
158
|
-
price {
|
|
159
|
-
currency
|
|
160
|
-
value
|
|
161
|
-
}
|
|
162
|
-
price_including_tax {
|
|
163
|
-
currency
|
|
164
|
-
value
|
|
165
|
-
}
|
|
166
|
-
row_total {
|
|
167
|
-
value
|
|
168
|
-
currency
|
|
169
|
-
}
|
|
170
|
-
row_total_including_tax {
|
|
171
|
-
value
|
|
172
|
-
currency
|
|
173
|
-
}
|
|
174
|
-
total_item_discount {
|
|
175
|
-
value
|
|
176
|
-
currency
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
quantity
|
|
180
|
-
errors {
|
|
181
|
-
code
|
|
182
|
-
message
|
|
183
|
-
}
|
|
184
|
-
... on SimpleCartItem {
|
|
185
|
-
customizable_options {
|
|
186
|
-
label
|
|
187
|
-
values {
|
|
188
|
-
label
|
|
189
|
-
value
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
... on VirtualCartItem {
|
|
194
|
-
customizable_options {
|
|
195
|
-
label
|
|
196
|
-
values {
|
|
197
|
-
label
|
|
198
|
-
value
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
... on ConfigurableCartItem {
|
|
203
|
-
customizable_options {
|
|
204
|
-
label
|
|
205
|
-
values {
|
|
206
|
-
label
|
|
207
|
-
value
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
configurable_options {
|
|
211
|
-
id
|
|
212
|
-
configurable_product_option_uid
|
|
213
|
-
option_label
|
|
214
|
-
configurable_product_option_value_uid
|
|
215
|
-
value_label
|
|
216
|
-
value_id
|
|
217
|
-
}
|
|
218
|
-
configured_variant {
|
|
219
|
-
thumbnail {
|
|
220
|
-
label
|
|
221
|
-
url
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
... on GiftCardCartItem {
|
|
226
|
-
sender_name
|
|
227
|
-
sender_email
|
|
228
|
-
recipient_name
|
|
229
|
-
recipient_email
|
|
230
|
-
customizable_options {
|
|
231
|
-
label
|
|
232
|
-
values {
|
|
233
|
-
label
|
|
234
|
-
value
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
... on DownloadableCartItem {
|
|
239
|
-
links {
|
|
240
|
-
title
|
|
241
|
-
}
|
|
242
|
-
customizable_options {
|
|
243
|
-
label
|
|
244
|
-
values {
|
|
245
|
-
label
|
|
246
|
-
value
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
94
|
}
|
|
253
|
-
`,
|
|
95
|
+
`,b=`
|
|
254
96
|
query getCart($cartId: String!) {
|
|
255
97
|
cart(cart_id: $cartId) {
|
|
256
98
|
id
|
|
257
|
-
...
|
|
258
|
-
...CartSummaryItems
|
|
99
|
+
...CheckoutData
|
|
259
100
|
}
|
|
260
101
|
}
|
|
261
|
-
${
|
|
262
|
-
|
|
263
|
-
`,V=`
|
|
102
|
+
${i}
|
|
103
|
+
`,C=`
|
|
264
104
|
query getCustomerCart {
|
|
265
105
|
cart: customerCart {
|
|
266
106
|
id
|
|
267
|
-
...
|
|
268
|
-
...CartSummaryItems
|
|
107
|
+
...CheckoutData
|
|
269
108
|
}
|
|
270
109
|
}
|
|
271
|
-
${
|
|
272
|
-
|
|
273
|
-
`;export{c as C,_ as a,V as b,R as g,E as t};
|
|
274
|
-
//# sourceMappingURL=getCart.graphql.js.map
|
|
110
|
+
${i}
|
|
111
|
+
`;export{i as C,C as a,b as g,v as t};
|
package/chunks/getStoreConfig.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{FetchGraphQL as se}from"@dropins/tools/fetch-graphql.js";import{events as oe}from"@dropins/tools/event-bus.js";import{Component as ae,options as H,isValidElement as ne,createContext as E}from"@dropins/tools/preact.js";import{useMemo as $,useContext as m,useState as P,useEffect as G,useReducer as le}from"@dropins/tools/preact-hooks.js";import{jsx as C}from"@dropins/tools/preact-jsx-runtime.js";const U=e=>{throw e instanceof DOMException&&e.name==="AbortError"||oe.emit("error",{source:"checkout",type:"network",error:e}),e};var ue=Symbol.for("preact-signals");function M(){if(v>1)v--;else{for(var e,i=!1;S!==void 0;){var t=S;for(S=void 0,w++;t!==void 0;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&Q(t))try{t.c()}catch(o){i||(e=o,i=!0)}t=r}}if(w=0,v--,i)throw e}}var n=void 0,S=void 0,v=0,w=0,O=0;function B(e){if(n!==void 0){var i=e.n;if(i===void 0||i.t!==n)return i={i:0,S:e,p:n.s,n:void 0,t:n,e:void 0,x:void 0,r:i},n.s!==void 0&&(n.s.n=i),n.s=i,e.n=i,32&n.f&&e.S(i),i;if(i.i===-1)return i.i=0,i.n!==void 0&&(i.n.p=i.p,i.p!==void 0&&(i.p.n=i.n),i.p=n.s,i.n=void 0,n.s.n=i,n.s=i),i}}function u(e){this.v=e,this.i=0,this.n=void 0,this.t=void 0}u.prototype.brand=ue;u.prototype.h=function(){return!0};u.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)};u.prototype.U=function(e){if(this.t!==void 0){var i=e.e,t=e.x;i!==void 0&&(i.x=t,e.e=void 0),t!==void 0&&(t.e=i,e.x=void 0),e===this.t&&(this.t=t)}};u.prototype.subscribe=function(e){var i=this;return I(function(){var t=i.value,r=n;n=void 0;try{e(t)}finally{n=r}})};u.prototype.valueOf=function(){return this.value};u.prototype.toString=function(){return this.value+""};u.prototype.toJSON=function(){return this.value};u.prototype.peek=function(){var e=n;n=void 0;try{return this.value}finally{n=e}};Object.defineProperty(u.prototype,"value",{get:function(){var e=B(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(w>100)throw new Error("Cycle detected");this.v=e,this.i++,O++,v++;try{for(var i=this.t;i!==void 0;i=i.x)i.t.N()}finally{M()}}}});function _(e){return new u(e)}function Q(e){for(var i=e.s;i!==void 0;i=i.n)if(i.S.i!==i.i||!i.S.h()||i.S.i!==i.i)return!0;return!1}function X(e){for(var i=e.s;i!==void 0;i=i.n){var t=i.S.n;if(t!==void 0&&(i.r=t),i.S.n=i,i.i=-1,i.n===void 0){e.s=i;break}}}function W(e){for(var i=e.s,t=void 0;i!==void 0;){var r=i.p;i.i===-1?(i.S.U(i),r!==void 0&&(r.n=i.n),i.n!==void 0&&(i.n.p=r)):t=i,i.S.n=i.r,i.r!==void 0&&(i.r=void 0),i=r}e.s=t}function y(e){u.call(this,void 0),this.x=e,this.s=void 0,this.g=O-1,this.f=4}(y.prototype=new u).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===O))return!0;if(this.g=O,this.f|=1,this.i>0&&!Q(this))return this.f&=-2,!0;var e=n;try{X(this),n=this;var i=this.x();(16&this.f||this.v!==i||this.i===0)&&(this.v=i,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return n=e,W(this),this.f&=-2,!0};y.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var i=this.s;i!==void 0;i=i.n)i.S.S(i)}u.prototype.S.call(this,e)};y.prototype.U=function(e){if(this.t!==void 0&&(u.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var i=this.s;i!==void 0;i=i.n)i.S.U(i)}};y.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(y.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=B(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function fe(e){return new y(e)}function Y(e){var i=e.u;if(e.u=void 0,typeof i=="function"){v++;var t=n;n=void 0;try{i()}catch(r){throw e.f&=-2,e.f|=8,L(e),r}finally{n=t,M()}}}function L(e){for(var i=e.s;i!==void 0;i=i.n)i.S.U(i);e.x=void 0,e.s=void 0,Y(e)}function de(e){if(n!==this)throw new Error("Out-of-order effect");W(this),n=e,this.f&=-2,8&this.f&&L(this),M()}function D(e){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}D.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var i=this.x();typeof i=="function"&&(this.u=i)}finally{e()}};D.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Y(this),X(this),v++;var e=n;return n=this,de.bind(this,e)};D.prototype.N=function(){2&this.f||(this.f|=2,this.o=S,S=this)};D.prototype.d=function(){this.f|=8,1&this.f||L(this)};function I(e){var i=new D(e);try{i.c()}catch(t){throw i.d(),t}return i.d.bind(i)}var A;function g(e,i){H[e]=i.bind(null,H[e]||function(){})}function R(e){A&&A(),A=e&&e.S()}function Z(e){var i=this,t=e.data,r=pe(t);r.value=t;var o=$(function(){for(var s=i.__v;s=s.__;)if(s.__c){s.__c.__$f|=4;break}return i.__$u.c=function(){var a;!ne(o.peek())&&((a=i.base)==null?void 0:a.nodeType)===3?i.base.data=o.peek():(i.__$f|=1,i.setState({}))},fe(function(){var a=r.value.value;return a===0?0:a===!0?"":a||""})},[]);return o.value}Z.displayName="_st";Object.defineProperties(u.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Z},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});g("__b",function(e,i){if(typeof i.type=="string"){var t,r=i.props;for(var o in r)if(o!=="children"){var s=r[o];s instanceof u&&(t||(i.__np=t={}),t[o]=s,r[o]=s.peek())}}e(i)});g("__r",function(e,i){R();var t,r=i.__c;r&&(r.__$f&=-2,(t=r.__$u)===void 0&&(r.__$u=t=function(o){var s;return I(function(){s=this}),s.c=function(){r.__$f|=1,r.setState({})},s}())),R(t),e(i)});g("__e",function(e,i,t,r){R(),e(i,t,r)});g("diffed",function(e,i){R();var t;if(typeof i.type=="string"&&(t=i.__e)){var r=i.__np,o=i.props;if(r){var s=t.U;if(s)for(var a in s){var f=s[a];f!==void 0&&!(a in r)&&(f.d(),s[a]=void 0)}else t.U=s={};for(var p in r){var h=s[p],T=r[p];h===void 0?(h=ce(t,p,T,o),s[p]=h):h.o(T,o)}}}e(i)});function ce(e,i,t,r){var o=i in e&&e.ownerSVGElement===void 0,s=_(t);return{o:function(a,f){s.value=a,r=f},d:I(function(){var a=s.value.value;r[i]!==a&&(r[i]=a,o?e[i]=a:a?e.setAttribute(i,a):e.removeAttribute(i))})}}g("unmount",function(e,i){if(typeof i.type=="string"){var t=i.__e;if(t){var r=t.U;if(r){t.U=void 0;for(var o in r){var s=r[o];s&&s.d()}}}}else{var a=i.__c;if(a){var f=a.__$u;f&&(a.__$u=void 0,f.d())}}e(i)});g("__h",function(e,i,t,r){(r<3||r===9)&&(i.__$f|=2),e(i,t,r)});ae.prototype.shouldComponentUpdate=function(e,i){var t=this.__$u;if(!(t&&t.s!==void 0||4&this.__$f)||3&this.__$f)return!0;for(var r in i)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 pe(e){return $(function(){return _(e)},[])}const he=_({pending:!1,data:void 0}),ve=_(null);I(()=>{ve.value||(he.value={data:null,pending:!1})});const _e=_({checked:!0,setByUser:!1}),ye=_({pending:!1,data:void 0});I(()=>{var e;(e=ye.value.data)!=null&&e.virtual&&(_e.value={checked:!1,setByUser:!1})});const ge=e=>e?e.filter(Boolean).filter(t=>(t==null?void 0:t.label)&&(t==null?void 0:t.value)).map(t=>({text:t.label,value:t.value})):[],Te=e=>e?e.filter(Boolean).filter(i=>(i==null?void 0:i.name)&&(i==null?void 0:i.value)):[],Se=e=>e?e.filter(Boolean).map(t=>({code:t.code,defaultValue:t.default_value||void 0,frontendInput:t.frontend_input||void 0,isDisabled:!1,isRequired:t.is_required,label:t.label||void 0,multilineCount:t.multiline_count||void 0,options:ge(t.options),sortOrder:t.sort_order||void 0,validateRules:Te(t.validate_rules)})):[],xe=e=>e==null;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||{}),Ee=(e=>(e.InStock="IN_STOCK",e.OutOfStock="OUT_OF_STOCK",e))(Ee||{}),b=(e=>(e.DisplayExcludingTax="DISPLAY_EXCLUDING_TAX",e.DisplayIncludingTax="DISPLAY_INCLUDING_TAX",e.DisplayTypeBoth="DISPLAY_TYPE_BOTH",e))(b||{}),me=(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))(me||{}),c=(e=>(e[e.ExcludingTax=1]="ExcludingTax",e[e.IncludingTax=2]="IncludingTax",e[e.IncludingAndExcludingTax=3]="IncludingAndExcludingTax",e))(c||{}),x=(e=>(e[e.Rows=0]="Rows",e[e.Quantity=1]="Quantity",e))(x||{});const Ce=e=>{if(e)return e.filter(i=>!!i).filter(i=>{const{two_letter_abbreviation:t,full_name_locale:r}=i;return!!t&&!!r}).map(i=>{const{two_letter_abbreviation:t,full_name_locale:r}=i;return{value:t,label:r}})},j=E(void 0);function Qe({children:e}){const[i,t]=P({});return G(()=>{Ge().then(r=>t({fields:r}))},[]),C(j.Provider,{value:i,children:e})}function Xe(){const e=m(j);if(e!==void 0)return e;throw new Error("useAddressFormFields must be used within an AddressFormFieldsProvider")}var De=(e=>(e.EMPTY="EMPTY",e.IN_PROGRESS="IN_PROGRESS",e.INIT="INIT",e.LOADING="LOADING",e.COMPLETE="COMPLETE",e))(De||{}),Ie=(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))(Ie||{});const be=(e,i)=>{const t=o=>{const s=o!==void 0,a=o==null?void 0:o.items,f=a!==void 0&&a.length>0;return s?s&&!f?"EMPTY":"IN_PROGRESS":"INIT"};let r=e;switch(e){case"INIT":i.type===0&&(r=t(i.payload));break;case"IN_PROGRESS":i.type===1&&(r="COMPLETE"),i.type===2&&(r="LOADING"),i.type===4&&(r="LOADING"),i.type===0&&(r=t(i.payload));break;case"EMPTY":case"LOADING":i.type===3&&(r="EMPTY"),i.type===0&&(r=t(i.payload))}return r},z=E(void 0),We=({children:e})=>{const[i,t]=le(be,"INIT"),r={state:i,dispatch:t};return C(z.Provider,{value:r,children:e})};function Ye(){const e=m(z);if(e!==void 0)return e;throw new Error("useCheckoutState must be used within a CheckoutStateProvider")}const K=E(void 0);function Ze({children:e}){const[i,t]=P({});return G(()=>{Me().then(r=>t({countries:r}))},[]),C(K.Provider,{value:i,children:e})}function je(){const e=m(K);if(e!==void 0)return e;throw new Error("useCountries must be used within a CountriesProvider")}const J=E({});function ze({children:e,services:i}){return C(J.Provider,{value:i,children:e})}function Ke(){const e=m(J);if(e!==void 0)return e;throw new Error("useServices must be used within a ServicesProvider")}const Oe="US",Re=10,l={defaultCountry:Oe,countriesWithRequiredRegion:[],displayStateIfOptional:!1,countriesWithOptionalZipCode:[],isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1,taxCartDisplay:{shoppingCartDisplayPrice:c.ExcludingTax,shoppingCartDisplayShipping:c.ExcludingTax,shoppingCartDisplaySubtotal:c.ExcludingTax,shoppingCartDisplayGiftWrapping:c.ExcludingTax,shoppingCartDisplayGrandTotal:!1,shoppingCartDisplayFullSummary:!1,shoppingCartDisplayZeroTax:!1},cartSummaryMaxItems:Re,cartSummaryTotalDisplay:x.Quantity},V=E(void 0),Je=({children:e})=>{const[i,t]=P();return G(()=>{Fe().then(r=>{t(r)}).catch(()=>{console.error("Failed to fetch store config"),t(l)})},[]),C(V.Provider,{value:{config:i},children:e})};function Ve(){const e=m(V);if(e!==void 0)return e;throw new Error("useStore must be used within a StoreProvider")}function Ae(e){return e===0?x.Rows:x.Quantity}function N(e){return e===1?c.ExcludingTax:e===2?c.IncludingTax:e===3?c.IncludingAndExcludingTax:c.ExcludingTax}function Ne(e){switch(e){case b.DisplayExcludingTax:return c.ExcludingTax;case b.DisplayIncludingTax:return c.IncludingTax;case b.DisplayTypeBoth:return c.IncludingAndExcludingTax}}function we(e){if(!e)return l;const{default_country:i,countries_with_required_region:t,display_state_if_optional:r,optional_zip_countries:o,is_guest_checkout_enabled:s,is_one_page_checkout_enabled:a,shopping_cart_display_price:f,shopping_cart_display_shipping:p,shopping_cart_display_subtotal:h,shopping_cart_display_tax_gift_wrapping:T,shopping_cart_display_grand_total:ee,shopping_cart_display_full_summary:ie,shopping_cart_display_zero_tax:te,max_items_in_order_summary:re,cart_summary_display_quantity:k}=e;return{defaultCountry:i||l.defaultCountry,countriesWithRequiredRegion:(t==null?void 0:t.split(","))||l.countriesWithRequiredRegion,displayStateIfOptional:r||l.displayStateIfOptional,countriesWithOptionalZipCode:(o==null?void 0:o.split(","))||l.countriesWithOptionalZipCode,isGuestCheckoutEnabled:s||l.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:a||l.isOnePageCheckoutEnabled,taxCartDisplay:{shoppingCartDisplayPrice:f?N(f):l.taxCartDisplay.shoppingCartDisplayPrice,shoppingCartDisplayShipping:p?N(p):l.taxCartDisplay.shoppingCartDisplayShipping,shoppingCartDisplaySubtotal:h?N(h):l.taxCartDisplay.shoppingCartDisplaySubtotal,shoppingCartDisplayGiftWrapping:T?Ne(T):l.taxCartDisplay.shoppingCartDisplayGiftWrapping,shoppingCartDisplayGrandTotal:ee||l.taxCartDisplay.shoppingCartDisplayGrandTotal,shoppingCartDisplayFullSummary:ie||l.taxCartDisplay.shoppingCartDisplayFullSummary,shoppingCartDisplayZeroTax:te||l.taxCartDisplay.shoppingCartDisplayZeroTax},cartSummaryMaxItems:re||l.cartSummaryMaxItems,cartSummaryTotalDisplay:xe(k)?l.cartSummaryTotalDisplay:Ae(k)}}const{setEndpoint:ei,setFetchGraphQlHeader:ii,removeFetchGraphQlHeader:ti,setFetchGraphQlHeaders:ri,fetchGraphQl:F,getConfig:si}=new se().getMethods(),Pe=`
|
|
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
2
|
query fetchAddressFormFields {
|
|
3
3
|
attributesForm(formCode: "customer_register_address") {
|
|
4
4
|
items {
|
|
@@ -27,33 +27,23 @@ import{FetchGraphQL as se}from"@dropins/tools/fetch-graphql.js";import{events as
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
`,
|
|
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
31
|
query getCountries {
|
|
32
32
|
countries {
|
|
33
33
|
two_letter_abbreviation
|
|
34
34
|
full_name_locale
|
|
35
35
|
}
|
|
36
|
-
}`,
|
|
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
37
|
query getStoreConfig {
|
|
38
38
|
storeConfig {
|
|
39
|
-
cart_summary_display_quantity
|
|
40
39
|
countries_with_required_region
|
|
41
40
|
default_country
|
|
42
41
|
display_state_if_optional
|
|
43
42
|
is_guest_checkout_enabled
|
|
44
43
|
is_one_page_checkout_enabled
|
|
45
44
|
locale
|
|
46
|
-
max_items_in_order_summary
|
|
47
45
|
optional_zip_countries
|
|
48
|
-
shopping_cart_display_full_summary
|
|
49
|
-
shopping_cart_display_grand_total
|
|
50
|
-
shopping_cart_display_price
|
|
51
|
-
shopping_cart_display_shipping
|
|
52
|
-
shopping_cart_display_subtotal
|
|
53
|
-
shopping_cart_display_tax_gift_wrapping
|
|
54
|
-
shopping_cart_display_zero_tax
|
|
55
46
|
store_code
|
|
56
47
|
}
|
|
57
48
|
}
|
|
58
|
-
`,
|
|
59
|
-
//# sourceMappingURL=getStoreConfig.js.map
|
|
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/chunks/initialize.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=initialize.js.map
|
|
1
|
+
import{i as t}from"./getStoreConfig.js";import{Initializer as a}from"@dropins/tools/lib.js";import{events as n}from"@dropins/tools/event-bus.js";const e=new a({init:async i=>{const o={guestViewCookieExpirationDays:30,...i};e.config.setConfig(o)},listeners:()=>[n.on("cart/data",i=>{t.cartId=(i==null?void 0:i.id)||null}),n.on("authenticated",i=>{t.authenticated=i},{eager:!0})]}),f=e.config;export{f as c,e as i};
|