@dropins/storefront-checkout 2.1.0-beta2 → 2.2.0-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/getCompanyCredit/getCompanyCredit.d.ts +4 -0
- package/api/getCompanyCredit/graphql/getCompanyCredit.graphql.d.ts +18 -0
- package/api/{setNegotiableQuoteBillingAddress → getCompanyCredit/graphql}/index.d.ts +1 -1
- package/{types/ComponentTypes.d.ts → api/getCompanyCredit/index.d.ts} +2 -2
- package/api/getStoreConfig/getStoreConfig.d.ts +1 -0
- package/api/graphql/CartAddressFragment.graphql.d.ts +1 -1
- package/api/graphql/NegotiableQuoteAddressFragment.graphql.d.ts +1 -1
- package/api/graphql/PaymentMethodFragment.graphql.d.ts +1 -1
- package/api/index.d.ts +1 -5
- package/api/initialize/initialize.d.ts +21 -3
- package/api/initialize/listeners.d.ts +3 -17
- package/api/initializeCheckout/initializeCheckout.d.ts +2 -2
- package/api/{setShippingAddress/graphql/setShippingAddressAndUseAsBilling.graphql.d.ts → setBillingAddress/graphql/index.d.ts} +3 -2
- package/api/{setPaymentMethod/graphql/setPaymentMethod.graphql.d.ts → setBillingAddress/graphql/setBillingAddressOnCartMutation.graphql.d.ts} +2 -2
- package/api/setBillingAddress/graphql/setBillingAddressOnQuoteMutation.graphql.d.ts +18 -0
- package/api/setBillingAddress/setBillingAddress.d.ts +2 -2
- package/api/setPaymentMethod/graphql/index.d.ts +19 -0
- package/api/{setBillingAddress/graphql/setBillingAddress.graphql.d.ts → setPaymentMethod/graphql/setPaymentMethodOnCart.graphql.d.ts} +2 -2
- package/api/{setNegotiableQuotePaymentMethod/graphql/index.d.ts → setPaymentMethod/graphql/setPaymentMethodOnQuote.graphql.d.ts} +2 -2
- package/api/setPaymentMethod/setPaymentMethod.d.ts +2 -2
- package/api/setShippingAddress/graphql/index.d.ts +21 -0
- package/api/setShippingAddress/graphql/setShippingAddressOnCartAndUseAsBillingMutation.graphql.d.ts +18 -0
- package/api/setShippingAddress/graphql/{setShippingAddress.graphql.d.ts → setShippingAddressOnCartMutation.graphql.d.ts} +2 -2
- package/api/{setNegotiableQuoteBillingAddress/graphql/index.d.ts → setShippingAddress/graphql/setShippingAddressOnQuote.graphql.d.ts} +2 -2
- package/api/setShippingAddress/graphql/setShippingAddressOnQuoteAndUseAsBillingMutation.graphql.d.ts +18 -0
- package/api/setShippingAddress/setShippingAddress.d.ts +1 -1
- package/api/setShippingMethods/graphql/index.d.ts +19 -0
- package/api/setShippingMethods/graphql/setShippingMethodsOnCart.graphql.d.ts +1 -1
- package/api/{setNegotiableQuotePaymentMethod/index.d.ts → setShippingMethods/graphql/setShippingMethodsOnQuote.graphql.d.ts} +2 -2
- package/api/setShippingMethods/index.d.ts +1 -0
- package/api/setShippingMethods/setShippingMethods.d.ts +3 -17
- package/api/synchronizeCheckout/synchronizeCheckout.d.ts +2 -2
- package/api.js +2 -137
- package/api.js.map +1 -1
- package/chunks/ConditionalWrapper.js +1 -1
- package/chunks/ConditionalWrapper.js.map +1 -1
- package/chunks/PaymentOnAccount2.js +4 -0
- package/chunks/PaymentOnAccount2.js.map +1 -0
- package/chunks/PurchaseOrder.js +4 -0
- package/chunks/PurchaseOrder.js.map +1 -0
- package/chunks/classifiers.js +4 -0
- package/chunks/classifiers.js.map +1 -0
- package/chunks/dom.js.map +1 -1
- package/chunks/events.js +4 -0
- package/chunks/events.js.map +1 -0
- package/chunks/events2.js +4 -0
- package/chunks/events2.js.map +1 -0
- package/chunks/fetch-graphql.js +2 -2
- package/chunks/fetch-graphql.js.map +1 -1
- package/chunks/getCompanyCredit.js +15 -0
- package/chunks/getCompanyCredit.js.map +1 -0
- package/chunks/guards.js +4 -0
- package/chunks/guards.js.map +1 -0
- package/chunks/render.js +10 -0
- package/chunks/render.js.map +1 -0
- package/chunks/setBillingAddress.js +25 -5
- package/chunks/setBillingAddress.js.map +1 -1
- package/chunks/setGuestEmailOnCart.js +4 -4
- package/chunks/setGuestEmailOnCart.js.map +1 -1
- package/chunks/setPaymentMethod.js +21 -6
- package/chunks/setPaymentMethod.js.map +1 -1
- package/chunks/setShippingAddress.js +109 -0
- package/chunks/setShippingAddress.js.map +1 -0
- package/chunks/setShippingMethods.js +18 -3
- package/chunks/setShippingMethods.js.map +1 -1
- package/chunks/synchronizeCheckout.js +13 -5
- package/chunks/synchronizeCheckout.js.map +1 -1
- package/chunks/transform-shipping-estimate.js +4 -0
- package/chunks/transform-shipping-estimate.js.map +1 -0
- package/chunks/transform-shipping-methods.js +4 -0
- package/chunks/transform-shipping-methods.js.map +1 -0
- package/chunks/values.js +1 -1
- package/chunks/values.js.map +1 -1
- package/components/AddressValidation/AddressValidation.d.ts +14 -0
- package/components/AddressValidation/index.d.ts +19 -0
- package/components/PaymentMethods/PaymentMethods.d.ts +1 -1
- package/components/PaymentOnAccount/PaymentOnAccount.d.ts +17 -0
- package/components/PaymentOnAccount/PaymentOnAccountSkeleton.d.ts +4 -0
- package/components/PaymentOnAccount/index.d.ts +20 -0
- package/components/PurchaseOrder/PurchaseOrder.d.ts +10 -0
- package/components/PurchaseOrder/index.d.ts +19 -0
- package/components/ShippingMethods/ShippingMethods.d.ts +1 -1
- package/components/index.d.ts +4 -1
- package/containers/AddressValidation/AddressValidation.d.ts +12 -0
- package/containers/AddressValidation/index.d.ts +19 -0
- package/containers/AddressValidation.d.ts +3 -0
- package/containers/AddressValidation.js +4 -0
- package/containers/AddressValidation.js.map +1 -0
- package/containers/BillToShippingAddress.js +1 -1
- package/containers/BillToShippingAddress.js.map +1 -1
- package/containers/EstimateShipping.js +1 -1
- package/containers/EstimateShipping.js.map +1 -1
- package/containers/LoginForm/LoginForm.d.ts +1 -1
- package/containers/LoginForm.js +1 -1
- package/containers/LoginForm.js.map +1 -1
- package/containers/MergedCartBanner.js +1 -1
- package/containers/MergedCartBanner.js.map +1 -1
- package/containers/OutOfStock.js +1 -1
- package/containers/OutOfStock.js.map +1 -1
- package/containers/PaymentMethods/PaymentMethods.d.ts +9 -8
- package/containers/PaymentMethods/handlers.d.ts +11 -0
- package/containers/PaymentMethods.js +1 -1
- package/containers/PaymentMethods.js.map +1 -1
- package/containers/PaymentOnAccount/PaymentOnAccount.d.ts +10 -0
- package/containers/PaymentOnAccount/index.d.ts +11 -0
- package/containers/PaymentOnAccount.d.ts +3 -0
- package/containers/PaymentOnAccount.js +4 -0
- package/containers/PaymentOnAccount.js.map +1 -0
- package/containers/PlaceOrder/PlaceOrder.d.ts +2 -1
- package/containers/PlaceOrder.js +1 -1
- package/containers/PlaceOrder.js.map +1 -1
- package/containers/PurchaseOrder/PurchaseOrder.d.ts +10 -0
- package/containers/PurchaseOrder/index.d.ts +19 -0
- package/containers/PurchaseOrder.d.ts +3 -0
- package/containers/PurchaseOrder.js +4 -0
- package/containers/PurchaseOrder.js.map +1 -0
- package/containers/ServerError/ServerError.d.ts +2 -1
- package/containers/ServerError.js +1 -1
- package/containers/ServerError.js.map +1 -1
- package/containers/ShippingMethods/ShippingMethods.d.ts +2 -2
- package/containers/ShippingMethods.js +1 -1
- package/containers/ShippingMethods.js.map +1 -1
- package/containers/TermsAndConditions.js +1 -1
- package/containers/TermsAndConditions.js.map +1 -1
- package/containers/index.d.ts +3 -0
- package/data/models/address.d.ts +9 -1
- package/data/models/api.d.ts +23 -10
- package/data/models/cart.d.ts +1 -8
- package/data/models/company-credit.d.ts +7 -0
- package/data/models/index.d.ts +1 -0
- package/data/models/payment-method.d.ts +2 -0
- package/data/models/quote.d.ts +1 -0
- package/data/models/values.d.ts +1 -1
- package/data/transforms/index.d.ts +3 -0
- package/data/transforms/transform-api.d.ts +12 -0
- package/data/transforms/transform-cart-address.d.ts +34 -35
- package/data/transforms/transform-company-credit.d.ts +7 -0
- package/data/transforms/transform-custom-attributes.d.ts +5 -0
- package/data/transforms/transform-quote-address.d.ts +29 -14
- package/fragments.js +84 -57
- package/fragments.js.map +1 -1
- package/i18n/en_US.json.d.ts +26 -0
- package/lib/enqueueRequest.d.ts +2 -3
- package/lib/errors/classifiers.d.ts +3 -1
- package/lib/errors/customErrors.d.ts +3 -0
- package/lib/events.d.ts +3 -2
- package/{api/setNegotiableQuoteShippingAddress/index.d.ts → lib/guards.d.ts} +2 -2
- package/lib/index.d.ts +1 -1
- package/lib/state.d.ts +5 -4
- package/lib/utils/api.d.ts +16 -0
- package/lib/utils/events.d.ts +10 -0
- package/lib/utils/forms.d.ts +5 -0
- package/lib/utils/fragments.d.ts +19 -0
- package/lib/utils/index.d.ts +24 -0
- package/lib/utils/meta.d.ts +19 -0
- package/lib/utils/transformers.d.ts +6 -0
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +4 -0
- package/lib/utils.js.map +1 -0
- package/package.json +1 -1
- package/render.js +4 -4
- package/render.js.map +1 -1
- package/tests/fixtures/fragments/cart.d.ts +46 -40
- package/tests/fixtures/fragments/shipping-address.d.ts +2 -1
- package/tests/fixtures/helpers/session-storage.d.ts +68 -0
- package/tests/fixtures/index.d.ts +1 -0
- package/tests/fixtures/models/index.d.ts +1 -1
- package/tests/fixtures/models/quote.d.ts +9 -0
- package/tests/fixtures/queries/get-company-credit.d.ts +14 -0
- package/tests/fixtures/queries/index.d.ts +1 -0
- package/types/api.d.ts +6 -0
- package/types/{TitleProps.d.ts → components.d.ts} +2 -1
- package/types/guards.d.ts +5 -0
- package/types/index.d.ts +22 -0
- package/types/storefront.d.ts +165 -0
- package/{api/setNegotiableQuoteBillingAddress/graphql/setNegotiableQuoteBillingAddress.graphql.d.ts → types/utils.d.ts} +3 -2
- package/api/setNegotiableQuoteBillingAddress/setNegotiableQuoteBillingAddress.d.ts +0 -6
- package/api/setNegotiableQuotePaymentMethod/graphql/setNegotiableQuotePaymentMethod.graphql.d.ts +0 -18
- package/api/setNegotiableQuotePaymentMethod/setNegotiableQuotePaymentMethod.d.ts +0 -6
- package/api/setNegotiableQuoteShippingAddress/graphql/index.d.ts +0 -18
- package/api/setNegotiableQuoteShippingAddress/graphql/setNegotiableQuoteShippingAddress.graphql.d.ts +0 -18
- package/api/setNegotiableQuoteShippingAddress/setNegotiableQuoteShippingAddress.d.ts +0 -6
- package/api/setNegotiableQuoteShippingMethods/graphql/index.d.ts +0 -18
- package/api/setNegotiableQuoteShippingMethods/graphql/setNegotiableQuoteShippingMethods.graphql.d.ts +0 -18
- package/api/setNegotiableQuoteShippingMethods/index.d.ts +0 -18
- package/api/setNegotiableQuoteShippingMethods/setNegotiableQuoteShippingMethods.d.ts +0 -18
- /package/lib/{dom.d.ts → utils/dom.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShippingMethods.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/Delivery.svg","/@dropins/storefront-checkout/src/components/ShippingMethods/ShippingMethodsSkeleton.tsx","/@dropins/storefront-checkout/src/components/ShippingMethods/ShippingMethods.tsx","/@dropins/storefront-checkout/src/containers/ShippingMethods/ShippingMethods.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgDelivery = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.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\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M15.1758 5.87573H19.0019L21.0394 10.7636\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.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\" }), /* @__PURE__ */ React.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\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M8.08792 7.63574H1.69824\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M7.11229 10.3619H1\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M5.16084 13.0402H1.92773\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M9.76172 16.7611H15.2809\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M2.38672 16.7611H5.17025\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }));\nexport default SvgDelivery;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\n\nexport const ShippingMethodsSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"shipping-methods-skeleton\">\n <SkeletonRow size=\"small\" variant=\"heading\" />\n <SkeletonRow size=\"small\" variant=\"empty\" />\n <SkeletonRow fullWidth={true} size=\"medium\" />\n <SkeletonRow fullWidth={true} size=\"medium\" />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WithConditionals } from '@/checkout/components/ConditionalWrapper/ConditionalWrapper';\nimport '@/checkout/components/ShippingMethods/ShippingMethods.css';\nimport { ShippingMethodsSkeleton } from '@/checkout/components/ShippingMethods/ShippingMethodsSkeleton';\nimport { ShippingMethod } from '@/checkout/data/models';\nimport { scrollToElement } from '@/checkout/lib';\nimport { UIComponentType } from '@/checkout/types/ComponentTypes';\nimport {\n Icon,\n IllustratedMessage,\n InLineAlert,\n Price,\n RadioButton,\n ToggleButton,\n} from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Delivery } from '@adobe-commerce/elsie/icons';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useEffect, useRef } from 'preact/hooks';\n\nexport interface ShippingMethodsProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n UIComponentType?: UIComponentType;\n busy?: boolean;\n error?: string | null;\n onDismissError?: () => void;\n onSelectionChange?: (method: ShippingMethod) => void;\n options: ShippingMethod[];\n selection: ShippingMethod | null;\n title?: VNode;\n}\n\nconst ShippingMethodsComponent: FunctionComponent<ShippingMethodsProps> = ({\n className,\n busy = false,\n onSelectionChange = () => {},\n options,\n selection,\n title,\n UIComponentType = 'RadioButton',\n error = null,\n onDismissError = () => {},\n ...props\n}) => {\n const translations = useText({\n EmptyState: 'Checkout.ShippingMethods.emptyState',\n });\n\n const hasError = error !== null;\n const errorRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (hasError && errorRef.current) {\n scrollToElement(errorRef.current);\n }\n }, [hasError]);\n\n const renderShippingMethod = (\n method: ShippingMethod,\n type: UIComponentType\n ) => {\n const commonProps = {\n busy,\n className: 'checkout-shipping-methods__method',\n key: method.value,\n name: 'shipping-method',\n value: method.value,\n onChange: () => onSelectionChange(method),\n };\n\n if (type === 'RadioButton') {\n return (\n <RadioButton\n {...commonProps}\n checked={selection?.value === method.value}\n data-testid=\"shipping-method-radioButton\"\n description={method.title}\n disabled={busy}\n id={method.value}\n label={\n <>\n <Price\n amount={method.amount.value}\n currency={method.amount.currency}\n />\n \n <span>{method.carrier.title}</span>\n </>\n }\n />\n );\n }\n\n return (\n <ToggleButton\n {...commonProps}\n data-testid=\"shipping-method-toggleButton\"\n label={\n <>\n <span>{method.carrier.title}</span>\n <Price\n amount={method.amount.value}\n currency={method.amount.currency}\n />\n </>\n }\n selected={selection?.value === method.value}\n />\n );\n };\n\n return (\n <div\n {...props}\n className={classes(['checkout-shipping-methods', className])}\n data-testid=\"checkout-shipping-methods\"\n >\n {title && (\n <VComponent className=\"checkout-shipping-methods__title\" node={title} />\n )}\n\n <div className={classes(['checkout-shipping-methods__content'])}>\n <div\n className={classes([\n 'checkout-shipping-methods__options',\n ['checkout-shipping-methods__options--busy', busy],\n [\n 'checkout-shipping-methods__options--toggleButton',\n UIComponentType === 'ToggleButton',\n ],\n ])}\n data-testid=\"checkout-shipping-methods-options\"\n >\n {options.length === 0 ? (\n <IllustratedMessage\n data-testid=\"checkout-shipping-methods-empty\"\n icon={<Icon source={Delivery} />}\n message={<p>{translations.EmptyState}</p>}\n />\n ) : (\n options.map((method: ShippingMethod) =>\n renderShippingMethod(method, UIComponentType)\n )\n )}\n </div>\n </div>\n\n {hasError && (\n <div\n ref={errorRef}\n className=\"checkout-shipping-methods__error\"\n data-testid=\"checkout-shipping-methods-alert\"\n >\n <InLineAlert\n heading={error}\n type=\"error\"\n variant=\"primary\"\n onDismiss={onDismissError}\n />\n </div>\n )}\n </div>\n );\n};\n\nexport const ShippingMethods = WithConditionals(\n ShippingMethodsComponent,\n ShippingMethodsSkeleton\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { setShippingMethodsOnCart as setShippingMethod } from '@/checkout/api';\nimport { ShippingMethods as ShippingMethodsComponent } from '@/checkout/components/ShippingMethods';\nimport { Cart, ShippingEstimate, ShippingMethod } from '@/checkout/data/models';\nimport { transformShippingEstimateShippingMethod } from '@/checkout/data/transforms';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingCartUpdates,\n hasPendingShippingEstimate,\n hasShippingAddress,\n notifyValues,\n} from '@/checkout/lib';\nimport { UIComponentType } from '@/checkout/types/ComponentTypes';\nimport { TitleProps } from '@/checkout/types/TitleProps';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container, Slot } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useCallback, useEffect, useMemo, useState } from 'preact/hooks';\n\ninterface CartSyncError {\n method: ShippingMethod;\n error: Error;\n}\n\nexport interface ShippingMethodsProps\n extends HTMLAttributes<HTMLDivElement>,\n TitleProps {\n UIComponentType?: UIComponentType;\n active?: boolean;\n autoSync?: boolean;\n onCartSyncError?: (error: CartSyncError) => void;\n onSelectionChange?: (method: ShippingMethod) => void;\n}\n\nfunction isMethodAvailable(\n method: ShippingMethod | null,\n options: ShippingMethod[]\n) {\n if (!method) return false;\n return options.some((option) => isEqual(option, method));\n}\n\nfunction isEqual(a: ShippingMethod | null, b: ShippingMethod | null) {\n if (!a || !b) return false;\n if (a.amount.value !== b.amount.value) return false;\n return a.code === b.code && a.carrier.code === b.carrier.code;\n}\n\nexport function emitShippingEstimateEvent(selection: ShippingMethod) {\n const shippingEstimatedEvent = events.lastPayload('shipping/estimate');\n\n if (!shippingEstimatedEvent) return;\n\n events.emit('shipping/estimate', {\n ...shippingEstimatedEvent,\n shippingMethod: transformShippingEstimateShippingMethod(selection),\n });\n}\n\nexport const ShippingMethods: Container<ShippingMethodsProps> = ({\n UIComponentType = 'RadioButton',\n active = true,\n autoSync = true,\n displayTitle = true,\n initialData,\n slots,\n onCartSyncError,\n onSelectionChange,\n ...props\n}) => {\n const [error, setError] = useState<string | null>(null);\n const [isVirtual, setIsVirtual] = useState(false);\n const [options, setOptions] = useState<ShippingMethod[] | undefined>();\n const [selection, setSelection] = useState<ShippingMethod | null>(null);\n\n const hasPendingUpdates = hasPendingCartUpdates.value;\n const hasPendingEstimations = hasPendingShippingEstimate.value;\n\n const { cartSyncError, defaultTitle } = useText({\n cartSyncError: 'Checkout.ShippingMethods.cartSyncError',\n defaultTitle: 'Checkout.ShippingMethods.title',\n });\n\n const handleDismissError = useCallback(() => {\n setError(null);\n }, []);\n\n const setUserSelection = useCallback(\n (shippingMethod: ShippingMethod | null) => {\n setError(null);\n setSelection((prev) => {\n if (isEqual(prev, shippingMethod)) return prev;\n notifyValues({ selectedShippingMethod: shippingMethod });\n return shippingMethod;\n });\n },\n []\n );\n\n const setUserSelectionOnCart = useCallback(\n async (selection: ShippingMethod, fallback?: ShippingMethod | null) => {\n if (!autoSync || !hasShippingAddress()) return;\n\n const shippingMethodInput = {\n method_code: selection.code,\n carrier_code: selection.carrier.code,\n };\n\n setShippingMethod([shippingMethodInput]).catch((error) => {\n setUserSelection(fallback ?? null);\n onCartSyncError?.({ method: selection, error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [autoSync, setUserSelection, onCartSyncError, cartSyncError]\n );\n\n const handleSelectionChange = useCallback(\n async (selection: ShippingMethod) => {\n const prevSelection = getValue('selectedShippingMethod');\n\n setUserSelection(selection);\n onSelectionChange?.(selection);\n\n if (!hasShippingAddress()) {\n emitShippingEstimateEvent(selection);\n }\n\n await setUserSelectionOnCart(selection, prevSelection);\n },\n [onSelectionChange, setUserSelection, setUserSelectionOnCart]\n );\n\n const handleCheckoutData = useCallback(\n (data: Cart | null) => {\n const isEmptyCart = !data || data.isEmpty;\n const isVirtualCart = Boolean(data?.isVirtual);\n\n if (isEmptyCart || isVirtualCart) {\n setIsVirtual(isVirtualCart);\n setUserSelection(null);\n setOptions([]);\n return;\n }\n\n const primaryAddress = data!.shippingAddresses?.[0];\n\n // If there is no primary address, options are handled by the shipping estimation\n if (!primaryAddress) return;\n\n const availableOptions = primaryAddress.availableShippingMethods ?? [];\n setOptions(availableOptions);\n\n // If there are no available options, reset the user selection\n if (availableOptions.length === 0) {\n setUserSelection(null);\n return;\n }\n\n const cartSelection = primaryAddress.selectedShippingMethod ?? null;\n\n const userSelection = getValue('selectedShippingMethod');\n const isAvailable = isMethodAvailable(userSelection, availableOptions);\n const haveSameSelection = isEqual(userSelection, cartSelection);\n\n // Handle user selection that's available but different from cart\n if (userSelection && isAvailable && !haveSameSelection) {\n setUserSelectionOnCart(userSelection, cartSelection);\n return;\n }\n\n // If no user selection or not available, decide what to do based on cart and available options\n if ((!userSelection || !isAvailable) && cartSelection) {\n setUserSelection(cartSelection);\n return;\n }\n\n if ((!userSelection || !isAvailable) && !cartSelection) {\n const newSelection = availableOptions[0];\n setUserSelection(newSelection);\n\n // Only sync to cart if autoSync is enabled\n if (autoSync) {\n setUserSelectionOnCart(newSelection);\n }\n }\n },\n [setUserSelectionOnCart, setUserSelection, autoSync]\n );\n\n const handleShippingEstimate = useCallback(\n (estimation: ShippingEstimate | undefined) => {\n if (estimation === undefined) return;\n\n const { shippingMethod, availableShippingMethods } = estimation;\n const selectedShippingMethod =\n availableShippingMethods?.find(\n (method) =>\n method.code === shippingMethod?.methodCode &&\n method.carrier.code === shippingMethod?.carrierCode\n ) ?? null;\n\n setOptions(availableShippingMethods);\n setUserSelection(selectedShippingMethod);\n },\n [setUserSelection]\n );\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n // When component becomes active, restore key state so handleCheckoutData can work properly\n const userSelection = getValue('selectedShippingMethod');\n if (userSelection) {\n setSelection(userSelection);\n }\n\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n handleCheckoutData,\n { eager: true }\n );\n\n return () => {\n onCheckoutInit?.off();\n };\n }, [active, handleCheckoutData]);\n\n useEffect(() => {\n if (!active) return;\n\n const onCheckoutUpdated = events.on(\n 'checkout/updated',\n handleCheckoutData,\n { eager: false }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n useEffect(() => {\n if (!active || hasShippingAddress()) return;\n\n const onShippingEstimate = events.on(\n 'shipping/estimate',\n handleShippingEstimate,\n { eager: true }\n );\n\n return () => {\n onShippingEstimate?.off();\n };\n }, [active, handleShippingEstimate]);\n\n const titleContent = useMemo(() => {\n if (!displayTitle) return undefined;\n\n return (\n <Slot name=\"checkout-shipping-methods-title\" slot={slots?.Title}>\n <h3>{defaultTitle}</h3>\n </Slot>\n );\n }, [displayTitle, slots?.Title, defaultTitle]);\n\n return (\n <ShippingMethodsComponent\n {...props}\n UIComponentType={UIComponentType}\n busy={hasPendingUpdates || hasPendingEstimations}\n error={error}\n initialized={options !== undefined}\n options={options ?? []}\n selection={selection}\n title={titleContent}\n visible={active && !isVirtual}\n onDismissError={handleDismissError}\n onSelectionChange={handleSelectionChange}\n />\n );\n};\n"],"names":["SvgDelivery","props","React","ShippingMethodsSkeleton","jsxs","Skeleton","jsx","SkeletonRow","ShippingMethodsComponent","className","busy","onSelectionChange","options","selection","title","UIComponentType","error","onDismissError","translations","useText","hasError","errorRef","useRef","useEffect","scrollToElement","renderShippingMethod","method","type","commonProps","RadioButton","Fragment","Price","ToggleButton","classes","VComponent","IllustratedMessage","Icon","Delivery","InLineAlert","ShippingMethods","WithConditionals","isMethodAvailable","option","isEqual","a","b","emitShippingEstimateEvent","shippingEstimatedEvent","events","transformShippingEstimateShippingMethod","active","autoSync","displayTitle","initialData","slots","onCartSyncError","setError","useState","isVirtual","setIsVirtual","setOptions","setSelection","hasPendingUpdates","hasPendingCartUpdates","hasPendingEstimations","hasPendingShippingEstimate","cartSyncError","defaultTitle","handleDismissError","useCallback","setUserSelection","shippingMethod","prev","notifyValues","setUserSelectionOnCart","fallback","hasShippingAddress","shippingMethodInput","setShippingMethod","handleSelectionChange","prevSelection","getValue","handleCheckoutData","data","isEmptyCart","isVirtualCart","primaryAddress","_a","availableOptions","cartSelection","userSelection","isAvailable","haveSameSelection","newSelection","handleShippingEstimate","estimation","availableShippingMethods","selectedShippingMethod","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","onCheckoutUpdated","onShippingEstimate","titleContent","useMemo","Slot"],"mappings":"2hCACA,MAAMA,GAAeC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAG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GAAA,MAAAA,EAAoB,KACtB,CAAA,EACC,CAACpD,EAAQ4C,CAAsB,CAAC,EAE7B,MAAAS,EAAeC,GAAQ,IAAM,CAC7B,GAACpD,EAGH,OAAA9C,EAACmG,GAAK,CAAA,KAAK,kCAAkC,KAAMnD,GAAA,YAAAA,EAAO,MACxD,SAAAhD,EAAC,KAAI,CAAA,SAAA6D,CAAa,CAAA,EACpB,GAED,CAACf,EAAcE,GAAA,YAAAA,EAAO,MAAOa,CAAY,CAAC,EAG3C,OAAA7D,EAACE,GAAA,CACE,GAAGP,EACJ,gBAAiBc,EACjB,KAAM+C,GAAqBE,EAC3B,MAAAhD,EACA,YAAaJ,IAAY,OACzB,QAASA,GAAW,CAAC,EACrB,UAAAC,EACA,MAAO0F,EACP,QAASrD,GAAU,CAACQ,EACpB,eAAgBU,EAChB,kBAAmBW,CAAA,CACrB,CAEJ","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"ShippingMethods.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/Delivery.svg","/@dropins/storefront-checkout/src/components/ShippingMethods/ShippingMethodsSkeleton.tsx","/@dropins/storefront-checkout/src/components/ShippingMethods/ShippingMethods.tsx","/@dropins/storefront-checkout/src/containers/ShippingMethods/ShippingMethods.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgDelivery = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.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\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M15.1758 5.87573H19.0019L21.0394 10.7636\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.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\" }), /* @__PURE__ */ React.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\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M8.08792 7.63574H1.69824\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M7.11229 10.3619H1\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M5.16084 13.0402H1.92773\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M9.76172 16.7611H15.2809\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M2.38672 16.7611H5.17025\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }));\nexport default SvgDelivery;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\n\nexport const ShippingMethodsSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"shipping-methods-skeleton\">\n <SkeletonRow size=\"small\" variant=\"heading\" />\n <SkeletonRow size=\"small\" variant=\"empty\" />\n <SkeletonRow fullWidth={true} size=\"medium\" />\n <SkeletonRow fullWidth={true} size=\"medium\" />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WithConditionals } from '@/checkout/components/ConditionalWrapper/ConditionalWrapper';\nimport '@/checkout/components/ShippingMethods/ShippingMethods.css';\nimport { ShippingMethodsSkeleton } from '@/checkout/components/ShippingMethods/ShippingMethodsSkeleton';\nimport { ShippingMethod } from '@/checkout/data/models';\nimport { scrollToElement } from '@/checkout/lib';\nimport { UIComponentType } from '@/checkout/types';\nimport {\n Icon,\n IllustratedMessage,\n InLineAlert,\n Price,\n RadioButton,\n ToggleButton,\n} from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Delivery } from '@adobe-commerce/elsie/icons';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useEffect, useRef } from 'preact/hooks';\n\nexport interface ShippingMethodsProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n UIComponentType?: UIComponentType;\n busy?: boolean;\n error?: string | null;\n onDismissError?: () => void;\n onSelectionChange?: (method: ShippingMethod) => void;\n options: ShippingMethod[];\n selection: ShippingMethod | null;\n title?: VNode;\n}\n\nconst ShippingMethodsComponent: FunctionComponent<ShippingMethodsProps> = ({\n className,\n busy = false,\n onSelectionChange = () => {},\n options,\n selection,\n title,\n UIComponentType = 'RadioButton',\n error = null,\n onDismissError = () => {},\n ...props\n}) => {\n const translations = useText({\n EmptyState: 'Checkout.ShippingMethods.emptyState',\n });\n\n const hasError = error !== null;\n const errorRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (hasError && errorRef.current) {\n scrollToElement(errorRef.current);\n }\n }, [hasError]);\n\n const renderShippingMethod = (\n method: ShippingMethod,\n type: UIComponentType\n ) => {\n const commonProps = {\n busy,\n className: 'checkout-shipping-methods__method',\n key: method.value,\n name: 'shipping-method',\n value: method.value,\n onChange: () => onSelectionChange(method),\n };\n\n if (type === 'RadioButton') {\n return (\n <RadioButton\n {...commonProps}\n checked={selection?.value === method.value}\n data-testid=\"shipping-method-radioButton\"\n description={method.title}\n disabled={busy}\n id={method.value}\n label={\n <>\n <Price\n amount={method.amount.value}\n currency={method.amount.currency}\n />\n \n <span>{method.carrier.title}</span>\n </>\n }\n />\n );\n }\n\n return (\n <ToggleButton\n {...commonProps}\n data-testid=\"shipping-method-toggleButton\"\n label={\n <>\n <span>{method.carrier.title}</span>\n <Price\n amount={method.amount.value}\n currency={method.amount.currency}\n />\n </>\n }\n selected={selection?.value === method.value}\n />\n );\n };\n\n return (\n <div\n {...props}\n className={classes(['checkout-shipping-methods', className])}\n data-testid=\"checkout-shipping-methods\"\n >\n {title && (\n <VComponent className=\"checkout-shipping-methods__title\" node={title} />\n )}\n\n <div className={classes(['checkout-shipping-methods__content'])}>\n <div\n className={classes([\n 'checkout-shipping-methods__options',\n ['checkout-shipping-methods__options--busy', busy],\n [\n 'checkout-shipping-methods__options--toggleButton',\n UIComponentType === 'ToggleButton',\n ],\n ])}\n data-testid=\"checkout-shipping-methods-options\"\n >\n {options.length === 0 ? (\n <IllustratedMessage\n data-testid=\"checkout-shipping-methods-empty\"\n icon={<Icon source={Delivery} />}\n message={<p>{translations.EmptyState}</p>}\n />\n ) : (\n options.map((method: ShippingMethod) =>\n renderShippingMethod(method, UIComponentType)\n )\n )}\n </div>\n </div>\n\n {hasError && (\n <div\n ref={errorRef}\n className=\"checkout-shipping-methods__error\"\n data-testid=\"checkout-shipping-methods-alert\"\n >\n <InLineAlert\n heading={error}\n type=\"error\"\n variant=\"primary\"\n onDismiss={onDismissError}\n />\n </div>\n )}\n </div>\n );\n};\n\nexport const ShippingMethods = WithConditionals(\n ShippingMethodsComponent,\n ShippingMethodsSkeleton\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { config, setShippingMethods } from '@/checkout/api';\nimport { ShippingMethods as ShippingMethodsComponent } from '@/checkout/components/ShippingMethods';\nimport {\n Cart,\n NegotiableQuote,\n ShippingEstimate,\n ShippingMethod,\n ShippingMethodInput,\n} from '@/checkout/data/models';\nimport { transformShippingEstimateShippingMethod } from '@/checkout/data/transforms';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingShippingEstimate,\n hasPendingUpdates,\n hasShippingAddress,\n notifyValues,\n} from '@/checkout/lib';\nimport { Filter, TitleProps, UIComponentType } from '@/checkout/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container, Slot } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useCallback, useEffect, useMemo, useState } from 'preact/hooks';\n\ninterface CartSyncError {\n method: ShippingMethod;\n error: Error;\n}\n\nexport type ShippingOptionsFilter = Filter<ShippingMethod>;\n\nexport interface ShippingMethodsProps\n extends HTMLAttributes<HTMLDivElement>,\n TitleProps {\n UIComponentType?: UIComponentType;\n active?: boolean;\n autoSync?: boolean;\n onCartSyncError?: (error: CartSyncError) => void;\n onSelectionChange?: (method: ShippingMethod) => void;\n}\n\nfunction isMethodAvailable(\n method: ShippingMethod | null,\n options: ShippingMethod[]\n) {\n if (!method) return false;\n return options.some((option) => isEqual(option, method));\n}\n\nfunction isEqual(a: ShippingMethod | null, b: ShippingMethod | null) {\n if (!a || !b) return false;\n if (a.amount.value !== b.amount.value) return false;\n return a.code === b.code && a.carrier.code === b.carrier.code;\n}\n\nexport function emitShippingEstimateEvent(selection: ShippingMethod) {\n const shippingEstimatedEvent = events.lastPayload('shipping/estimate');\n\n if (!shippingEstimatedEvent) return;\n\n events.emit('shipping/estimate', {\n ...shippingEstimatedEvent,\n shippingMethod: transformShippingEstimateShippingMethod(selection),\n });\n}\n\nexport const ShippingMethods: Container<ShippingMethodsProps> = ({\n UIComponentType = 'RadioButton',\n active = true,\n autoSync = true,\n displayTitle = true,\n initialData,\n slots,\n onCartSyncError,\n onSelectionChange,\n ...props\n}) => {\n const [error, setError] = useState<string | null>(null);\n const [isVirtual, setIsVirtual] = useState(false);\n const [options, setOptions] = useState<ShippingMethod[] | undefined>();\n const [selection, setSelection] = useState<ShippingMethod | null>(null);\n\n const hasQueuedUpdates = hasPendingUpdates.value;\n const hasPendingEstimations = hasPendingShippingEstimate.value;\n\n const { cartSyncError, defaultTitle } = useText({\n cartSyncError: 'Checkout.ShippingMethods.cartSyncError',\n defaultTitle: 'Checkout.ShippingMethods.title',\n });\n\n const filterOptions = useCallback(\n (shippingMethods: ShippingMethod[] | undefined) => {\n if (!shippingMethods || shippingMethods.length === 0) return [];\n const { shipping } = config.getConfig();\n if (!shipping?.filterOptions) return shippingMethods;\n return shippingMethods.filter(shipping.filterOptions);\n },\n []\n );\n\n const preselectOption = useCallback((shippingMethods: ShippingMethod[]) => {\n if (shippingMethods.length === 0) return null;\n const { defaults } = config.getConfig();\n return defaults!.selectedShippingMethod!(shippingMethods);\n }, []);\n\n const filteredOptions = useMemo(() => {\n return filterOptions(options);\n }, [options, filterOptions]);\n\n const handleDismissError = useCallback(() => {\n setError(null);\n }, []);\n\n const setUserSelection = useCallback(\n (shippingMethod: ShippingMethod | null) => {\n setError(null);\n setSelection((prev) => {\n if (isEqual(prev, shippingMethod)) return prev;\n notifyValues({ selectedShippingMethod: shippingMethod });\n return shippingMethod;\n });\n },\n []\n );\n\n const setUserSelectionOnCart = useCallback(\n async (selection: ShippingMethod, fallback?: ShippingMethod | null) => {\n if (!autoSync || !hasShippingAddress()) return;\n\n const shippingMethodInput: ShippingMethodInput = {\n carrierCode: selection.carrier.code,\n methodCode: selection.code,\n };\n\n setShippingMethods([shippingMethodInput]).catch((error) => {\n setUserSelection(fallback ?? null);\n onCartSyncError?.({ method: selection, error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [autoSync, setUserSelection, onCartSyncError, cartSyncError]\n );\n\n const handleSelectionChange = useCallback(\n async (selection: ShippingMethod) => {\n const prevSelection = getValue('selectedShippingMethod');\n\n setUserSelection(selection);\n onSelectionChange?.(selection);\n\n if (!hasShippingAddress()) {\n emitShippingEstimateEvent(selection);\n }\n\n await setUserSelectionOnCart(selection, prevSelection);\n },\n [onSelectionChange, setUserSelection, setUserSelectionOnCart]\n );\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const isEmptyCart = !data || data.isEmpty;\n const isVirtualCart = Boolean(data?.isVirtual);\n\n if (isEmptyCart || isVirtualCart) {\n setIsVirtual(isVirtualCart);\n setUserSelection(null);\n setOptions([]);\n return;\n }\n\n const primaryAddress = data!.shippingAddresses?.[0];\n\n // If there is no primary address, options are handled by the shipping estimation\n if (!primaryAddress) return;\n\n const availableOptions = primaryAddress.availableShippingMethods ?? [];\n const filteredOptions = filterOptions(availableOptions);\n setOptions(availableOptions);\n\n // If there are no filtered options, reset the user selection\n if (filteredOptions.length === 0) {\n setUserSelection(null);\n return;\n }\n\n const cartSelection = primaryAddress.selectedShippingMethod ?? null;\n\n const userSelection = getValue('selectedShippingMethod');\n const isAvailable = isMethodAvailable(userSelection, filteredOptions);\n const haveSameSelection = isEqual(userSelection, cartSelection);\n\n // Handle user selection that's available but different from cart\n if (userSelection && isAvailable && !haveSameSelection) {\n setUserSelectionOnCart(userSelection, cartSelection);\n return;\n }\n\n // If no user selection or not available, decide what to do based on cart and filtered options\n if ((!userSelection || !isAvailable) && cartSelection) {\n // Check if cart selection is still available after filtering\n const isCartSelectionAvailable = isMethodAvailable(\n cartSelection,\n filteredOptions\n );\n if (isCartSelectionAvailable) {\n setUserSelection(cartSelection);\n return;\n }\n }\n\n if (\n (!userSelection || !isAvailable) &&\n (!cartSelection || !isMethodAvailable(cartSelection, filteredOptions))\n ) {\n const newSelection = preselectOption(filteredOptions);\n setUserSelection(newSelection);\n if (newSelection) setUserSelectionOnCart(newSelection);\n }\n },\n [filterOptions, preselectOption, setUserSelection, setUserSelectionOnCart]\n );\n\n const handleShippingEstimate = useCallback(\n (estimation: ShippingEstimate | undefined) => {\n if (estimation === undefined) return;\n\n const { shippingMethod, availableShippingMethods } = estimation;\n\n const selectedShippingMethod =\n availableShippingMethods?.find(\n (method) =>\n method.code === shippingMethod?.methodCode &&\n method.carrier.code === shippingMethod?.carrierCode\n ) ?? null;\n\n setOptions(availableShippingMethods);\n setUserSelection(selectedShippingMethod);\n },\n [setUserSelection]\n );\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n // When component becomes active, restore key state so handleCheckoutData can work properly\n const userSelection = getValue('selectedShippingMethod');\n if (userSelection) {\n setSelection(userSelection);\n }\n\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n handleCheckoutData,\n { eager: true }\n );\n\n return () => {\n onCheckoutInit?.off();\n };\n }, [active, handleCheckoutData]);\n\n useEffect(() => {\n if (!active) return;\n\n const onCheckoutUpdated = events.on(\n 'checkout/updated',\n handleCheckoutData,\n { eager: false }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n useEffect(() => {\n if (!active || hasShippingAddress()) return;\n\n const onShippingEstimate = events.on(\n 'shipping/estimate',\n handleShippingEstimate,\n { eager: true }\n );\n\n return () => {\n onShippingEstimate?.off();\n };\n }, [active, handleShippingEstimate]);\n\n const titleContent = useMemo(() => {\n if (!displayTitle) return undefined;\n\n return (\n <Slot name=\"checkout-shipping-methods-title\" slot={slots?.Title}>\n <h3>{defaultTitle}</h3>\n </Slot>\n );\n }, [displayTitle, slots?.Title, defaultTitle]);\n\n return (\n <ShippingMethodsComponent\n {...props}\n UIComponentType={UIComponentType}\n busy={hasQueuedUpdates || hasPendingEstimations}\n error={error}\n initialized={options !== undefined}\n options={filteredOptions}\n selection={selection}\n title={titleContent}\n visible={active && !isVirtual}\n onDismissError={handleDismissError}\n onSelectionChange={handleSelectionChange}\n />\n );\n};\n"],"names":["SvgDelivery","props","React","ShippingMethodsSkeleton","jsxs","Skeleton","jsx","SkeletonRow","ShippingMethodsComponent","className","busy","onSelectionChange","options","selection","title","UIComponentType","error","onDismissError","translations","useText","hasError","errorRef","useRef","useEffect","scrollToElement","renderShippingMethod","method","type","commonProps","RadioButton","Fragment","Price","ToggleButton","classes","VComponent","IllustratedMessage","Icon","Delivery","InLineAlert","ShippingMethods","WithConditionals","isMethodAvailable","option","isEqual","a","b","emitShippingEstimateEvent","shippingEstimatedEvent","events","transformShippingEstimateShippingMethod","active","autoSync","displayTitle","initialData","slots","onCartSyncError","setError","useState","isVirtual","setIsVirtual","setOptions","setSelection","hasQueuedUpdates","hasPendingUpdates","hasPendingEstimations","hasPendingShippingEstimate","cartSyncError","defaultTitle","filterOptions","useCallback","shippingMethods","shipping","config","preselectOption","defaults","filteredOptions","useMemo","handleDismissError","setUserSelection","shippingMethod","prev","notifyValues","setUserSelectionOnCart","fallback","hasShippingAddress","shippingMethodInput","setShippingMethods","handleSelectionChange","prevSelection","getValue","handleCheckoutData","data","isEmptyCart","isVirtualCart","primaryAddress","_a","availableOptions","cartSelection","userSelection","isAvailable","haveSameSelection","newSelection","handleShippingEstimate","estimation","availableShippingMethods","selectedShippingMethod","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","onCheckoutUpdated","onShippingEstimate","titleContent","Slot"],"mappings":"2uCACA,MAAMA,GAAeC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,GAAyBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,oEAAqE,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAS,CAAA,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,2CAA4C,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,iQAAkQ,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAS,CAAA,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EA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QwC,CAAkB,CAAC,EAE/BnE,EAAU,IAAM,CACV,GAAA,CAAC2B,GAAUkC,IAAsB,OAErC,MAAM0B,EAAqB9D,EAAO,GAChC,oBACAsD,EACA,CAAE,MAAO,EAAK,CAChB,EAEA,MAAO,IAAM,CACXQ,GAAA,MAAAA,EAAoB,KACtB,CAAA,EACC,CAAC5D,EAAQoD,CAAsB,CAAC,EAE7B,MAAAS,GAAenC,EAAQ,IAAM,CAC7B,GAACxB,EAGH,OAAA9C,EAAC0G,GAAK,CAAA,KAAK,kCAAkC,KAAM1D,GAAA,YAAAA,EAAO,MACxD,SAAAhD,EAAC,KAAI,CAAA,SAAA6D,CAAa,CAAA,EACpB,GAED,CAACf,EAAcE,GAAA,YAAAA,EAAO,MAAOa,CAAY,CAAC,EAG3C,OAAA7D,EAACE,GAAA,CACE,GAAGP,EACJ,gBAAiBc,EACjB,KAAM+C,IAAoBE,GAC1B,MAAAhD,EACA,YAAaJ,IAAY,OACzB,QAAS+D,GACT,UAAA9D,EACA,MAAOkG,GACP,QAAS7D,GAAU,CAACQ,EACpB,eAAgBmB,GAChB,kBAAmBU,EAAA,CACrB,CAEJ","x_google_ignoreList":[0]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as e,jsxs as M}from"@dropins/tools/preact-jsx-runtime.js"
|
|
3
|
+
import{jsx as e,jsxs as M}from"@dropins/tools/preact-jsx-runtime.js";import{p as v}from"../chunks/TermsAndConditions.js";import{classes as f,VComponent as S,Slot as b}from"@dropins/tools/lib.js";import{Skeleton as N,SkeletonRow as U,Checkbox as w}from"@dropins/tools/components.js";/* empty css */import{s as E}from"../chunks/fetch-graphql.js";import{A as V}from"../chunks/checkout.js";import{events as W}from"@dropins/tools/event-bus.js";import{a as j}from"../chunks/events2.js";import"@dropins/tools/preact-compat.js";/* empty css *//* empty css *//* empty css */import{useState as g,useEffect as y}from"@dropins/tools/preact-hooks.js";import{W as D}from"../chunks/ConditionalWrapper.js";import{useText as H,MarkupText as L}from"@dropins/tools/i18n.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const P=({html:n})=>{const t=v.sanitize(n,{ADD_ATTR:["target"]});return t===""?null:e("span",{dangerouslySetInnerHTML:{__html:t}})},R=()=>e(N,{className:"checkout-terms-and-conditions-skeleton","data-testid":"checkout-terms-and-conditions-skeleton",children:e(U,{fullWidth:!0,size:"small",variant:"row"})}),$=({className:n,agreements:t,error:r,...s})=>e("div",{className:"checkout-terms-and-conditions","data-testid":"checkout-terms-and-conditions",children:M("form",{...s,noValidate:!0,className:f(["checkout-terms-and-conditions__form",n]),"data-testid":"checkout-terms-and-conditions-form",name:"checkout-terms-and-conditions__form",children:[t&&e(S,{className:f(["checkout-terms-and-conditions__agreements"]),"data-testid":"checkout-terms-and-conditions-agreements",node:t}),r&&e("div",{className:"checkout-terms-and-conditions__error","data-testid":"checkout-terms-and-conditions-error",children:r})]})}),q=D($,R),de=({active:n=!0,slots:t,...r})=>{var c;const[s,d]=g(!1),[k,m]=g(""),{errorMessage:_}=H({errorMessage:"Checkout.TermsAndConditions.error"}),i=((c=E.config)==null?void 0:c.agreementsEnabled)===!1,A=()=>{m("")},C=()=>{m(_)};return y(()=>{if(!n||i)return;if(j()){d(!0);return}const o=W.on("checkout/initialized",()=>{d(!0)},{eager:!0});return()=>{o==null||o.off()}},[n,i]),e(q,{...r,agreements:e(b,{context:{appendAgreement(l){this._registerMethod((...o)=>{const u=l(...o);if(!u)return;const{mode:T,name:p,text:a,translationId:h}=u;if(!a&&!h){console.warn(`The agreement ${p} is misconfigured. Please provide a text or a translationId.`);return}const x=a?e(P,{html:a}):e(L,{id:h}),z=e(w,{checked:T===V.AUTO,label:x,name:p,required:!0,onChange:A,onInvalid:C});this._setProps(I=>({children:[...I.children||[],z]}))})}},name:"Agreements",slot:t==null?void 0:t.Agreements}),error:k,initialized:s,visible:n&&!i})};export{de as TermsAndConditions,de as default};
|
|
4
4
|
//# sourceMappingURL=TermsAndConditions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TermsAndConditions.js","sources":["/@dropins/storefront-checkout/src/components/Markup/Markup.tsx","/@dropins/storefront-checkout/src/components/TermsAndConditions/TermsAndConditionsSkeleton.tsx","/@dropins/storefront-checkout/src/components/TermsAndConditions/TermsAndConditions.tsx","/@dropins/storefront-checkout/src/containers/TermsAndConditions/TermsAndConditions.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport DOMPurify from 'dompurify';\nimport { FunctionComponent } from 'preact';\n\ninterface MarkupProps {\n html: string;\n}\n\nexport const Markup: FunctionComponent<MarkupProps> = ({ html }) => {\n const sanitizedHtml = DOMPurify.sanitize(html, { ADD_ATTR: ['target'] });\n if (sanitizedHtml === '') return null;\n // eslint-disable-next-line react/no-danger\n return <span dangerouslySetInnerHTML={{ __html: sanitizedHtml }} />;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const TermsAndConditionsSkeleton: FunctionComponent = () => {\n return (\n <Skeleton\n className=\"checkout-terms-and-conditions-skeleton\"\n data-testid=\"checkout-terms-and-conditions-skeleton\"\n >\n <SkeletonRow fullWidth={true} size=\"small\" variant=\"row\" />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WithConditionals } from '@/checkout/components';\nimport '@/checkout/components/TermsAndConditions/TermsAndConditions.css';\nimport { TermsAndConditionsSkeleton } from '@/checkout/components/TermsAndConditions/TermsAndConditionsSkeleton';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface TermsAndConditionsProps\n extends HTMLAttributes<HTMLFormElement> {\n agreements?: VNode;\n error?: string;\n}\n\nconst TermsAndConditionsComponent: FunctionComponent<\n TermsAndConditionsProps\n> = ({ className, agreements, error, ...props }) => {\n return (\n <div\n className=\"checkout-terms-and-conditions\"\n data-testid=\"checkout-terms-and-conditions\"\n >\n <form\n {...props}\n noValidate\n className={classes(['checkout-terms-and-conditions__form', className])}\n data-testid=\"checkout-terms-and-conditions-form\"\n name=\"checkout-terms-and-conditions__form\"\n >\n {agreements && (\n <VComponent\n className={classes(['checkout-terms-and-conditions__agreements'])}\n data-testid=\"checkout-terms-and-conditions-agreements\"\n node={agreements}\n />\n )}\n\n {error && (\n <div\n className=\"checkout-terms-and-conditions__error\"\n data-testid=\"checkout-terms-and-conditions-error\"\n >\n {error}\n </div>\n )}\n </form>\n </div>\n );\n};\n\nexport const TermsAndConditions = WithConditionals(\n TermsAndConditionsComponent,\n TermsAndConditionsSkeleton\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Markup } from '@/checkout/components';\nimport { TermsAndConditions as TermsAndConditionsComponent } from '@/checkout/components/TermsAndConditions';\nimport { AgreementMode } from '@/checkout/data/models';\nimport { getLatestCheckoutUpdate, state } from '@/checkout/lib';\nimport { Checkbox } from '@adobe-commerce/elsie/components';\nimport { MarkupText, useText } from '@adobe-commerce/elsie/i18n';\nimport {\n Container,\n Slot,\n SlotMethod,\n SlotProps,\n} from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { useEffect, useState } from 'preact/hooks';\n\nexport interface TermsAndConditionsProps {\n active?: boolean;\n slots?: {\n Agreements?: SlotProps<{\n appendAgreement: SlotMethod<{\n name: string;\n mode: AgreementMode;\n translationId?: string;\n text?: string;\n }>;\n }>;\n };\n}\n\nexport const TermsAndConditions: Container<TermsAndConditionsProps> = ({\n active = true,\n slots,\n ...props\n}) => {\n const [isInitialized, setIsInitialized] = useState(false);\n const [error, setError] = useState<string>('');\n\n const { errorMessage } = useText({\n errorMessage: 'Checkout.TermsAndConditions.error',\n });\n\n const disabledViaConfig = state.config?.agreementsEnabled === false;\n\n const handleChange = () => {\n setError('');\n };\n\n const handleInvalid = () => {\n setError(errorMessage);\n };\n\n useEffect(() => {\n if (!active || disabledViaConfig) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n setIsInitialized(true);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n () => {\n setIsInitialized(true);\n },\n { eager: true }\n );\n return () => {\n onCheckoutInit?.off();\n };\n }, [active, disabledViaConfig]);\n\n return (\n <TermsAndConditionsComponent\n {...props}\n agreements={\n <Slot\n context={{\n appendAgreement(callback) {\n this._registerMethod((...attrs) => {\n const _agreement = callback(...attrs);\n\n if (!_agreement) return;\n\n const { mode, name, text, translationId } = _agreement;\n\n if (!text && !translationId) {\n console.warn(\n `The agreement ${name} is misconfigured. Please provide a text or a translationId.`\n );\n return;\n }\n\n const label = text ? (\n <Markup html={text} />\n ) : (\n <MarkupText id={translationId!} />\n );\n\n const agreement = (\n <Checkbox\n checked={mode === AgreementMode.AUTO}\n label={label}\n name={name}\n required={true}\n onChange={handleChange}\n onInvalid={handleInvalid}\n />\n );\n\n this._setProps((prev: any) => ({\n children: [...(prev.children || []), agreement],\n }));\n });\n },\n }}\n name=\"Agreements\"\n slot={slots?.Agreements}\n />\n }\n error={error}\n initialized={isInitialized}\n visible={active && !disabledViaConfig}\n />\n );\n};\n"],"names":["Markup","html","sanitizedHtml","DOMPurify","TermsAndConditionsSkeleton","jsx","Skeleton","SkeletonRow","TermsAndConditionsComponent","className","agreements","error","props","jsxs","classes","VComponent","TermsAndConditions","WithConditionals","active","slots","isInitialized","setIsInitialized","useState","setError","errorMessage","useText","disabledViaConfig","_a","state","handleChange","handleInvalid","useEffect","getLatestCheckoutUpdate","onCheckoutInit","events","Slot","callback","attrs","_agreement","mode","name","text","translationId","label","MarkupText","agreement","Checkbox","AgreementMode","prev"],"mappings":"m3BAwBO,MAAMA,EAAyC,CAAC,CAAE,KAAAC,KAAW,CAC5D,MAAAC,EAAgBC,EAAU,SAASF,EAAM,CAAE,SAAU,CAAC,QAAQ,EAAG,EACnE,OAAAC,IAAkB,GAAW,OAEzB,OAAK,CAAA,wBAAyB,CAAE,OAAQA,GAAiB,CACnE,ECTaE,EAAgD,IAEzDC,EAACC,EAAA,CACC,UAAU,yCACV,cAAY,yCAEZ,WAACC,EAAY,CAAA,UAAW,GA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B,CAAC,EAG5BrB,EAACG,EAAA,CACE,GAAGI,EACJ,WACEP,EAAC8B,EAAA,CACC,QAAS,CACP,gBAAgBC,EAAU,CACnB,KAAA,gBAAgB,IAAIC,IAAU,CAC3B,MAAAC,EAAaF,EAAS,GAAGC,CAAK,EAEpC,GAAI,CAACC,EAAY,OAEjB,KAAM,CAAE,KAAAC,EAAM,KAAAC,EAAM,KAAAC,EAAM,cAAAC,CAAkB,EAAAJ,EAExC,GAAA,CAACG,GAAQ,CAACC,EAAe,CACnB,QAAA,KACN,iBAAiBF,CAAI,8DACvB,EACA,MAAA,CAGI,MAAAG,EAAQF,EACZpC,EAACL,EAAO,CAAA,KAAMyC,CAAM,CAAA,EAEpBpC,EAACuC,EAAW,CAAA,GAAIF,CAAgB,CAAA,EAG5BG,EACJxC,EAACyC,EAAA,CACC,QAASP,IAASQ,EAAc,KAChC,MAAAJ,EACA,KAAAH,EACA,SAAU,GACV,SAAUX,EACV,UAAWC,CAAA,CACb,EAGG,KAAA,UAAWkB,IAAe,CAC7B,SAAU,CAAC,GAAIA,EAAK,UAAY,GAAKH,CAAS,CAAA,EAC9C,CAAA,CACH,CAAA,CAEL,EACA,KAAK,aACL,KAAM1B,GAAA,YAAAA,EAAO,UAAA,CACf,EAEF,MAAAR,EACA,YAAaS,EACb,QAASF,GAAU,CAACQ,CAAA,CACtB,CAEJ"}
|
|
1
|
+
{"version":3,"file":"TermsAndConditions.js","sources":["/@dropins/storefront-checkout/src/components/Markup/Markup.tsx","/@dropins/storefront-checkout/src/components/TermsAndConditions/TermsAndConditionsSkeleton.tsx","/@dropins/storefront-checkout/src/components/TermsAndConditions/TermsAndConditions.tsx","/@dropins/storefront-checkout/src/containers/TermsAndConditions/TermsAndConditions.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport DOMPurify from 'dompurify';\nimport { FunctionComponent } from 'preact';\n\ninterface MarkupProps {\n html: string;\n}\n\nexport const Markup: FunctionComponent<MarkupProps> = ({ html }) => {\n const sanitizedHtml = DOMPurify.sanitize(html, { ADD_ATTR: ['target'] });\n if (sanitizedHtml === '') return null;\n // eslint-disable-next-line react/no-danger\n return <span dangerouslySetInnerHTML={{ __html: sanitizedHtml }} />;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const TermsAndConditionsSkeleton: FunctionComponent = () => {\n return (\n <Skeleton\n className=\"checkout-terms-and-conditions-skeleton\"\n data-testid=\"checkout-terms-and-conditions-skeleton\"\n >\n <SkeletonRow fullWidth={true} size=\"small\" variant=\"row\" />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WithConditionals } from '@/checkout/components';\nimport '@/checkout/components/TermsAndConditions/TermsAndConditions.css';\nimport { TermsAndConditionsSkeleton } from '@/checkout/components/TermsAndConditions/TermsAndConditionsSkeleton';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface TermsAndConditionsProps\n extends HTMLAttributes<HTMLFormElement> {\n agreements?: VNode;\n error?: string;\n}\n\nconst TermsAndConditionsComponent: FunctionComponent<\n TermsAndConditionsProps\n> = ({ className, agreements, error, ...props }) => {\n return (\n <div\n className=\"checkout-terms-and-conditions\"\n data-testid=\"checkout-terms-and-conditions\"\n >\n <form\n {...props}\n noValidate\n className={classes(['checkout-terms-and-conditions__form', className])}\n data-testid=\"checkout-terms-and-conditions-form\"\n name=\"checkout-terms-and-conditions__form\"\n >\n {agreements && (\n <VComponent\n className={classes(['checkout-terms-and-conditions__agreements'])}\n data-testid=\"checkout-terms-and-conditions-agreements\"\n node={agreements}\n />\n )}\n\n {error && (\n <div\n className=\"checkout-terms-and-conditions__error\"\n data-testid=\"checkout-terms-and-conditions-error\"\n >\n {error}\n </div>\n )}\n </form>\n </div>\n );\n};\n\nexport const TermsAndConditions = WithConditionals(\n TermsAndConditionsComponent,\n TermsAndConditionsSkeleton\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Markup } from '@/checkout/components';\nimport { TermsAndConditions as TermsAndConditionsComponent } from '@/checkout/components/TermsAndConditions';\nimport { AgreementMode } from '@/checkout/data/models';\nimport { getLatestCheckoutUpdate, state } from '@/checkout/lib';\nimport { Checkbox } from '@adobe-commerce/elsie/components';\nimport { MarkupText, useText } from '@adobe-commerce/elsie/i18n';\nimport {\n Container,\n Slot,\n SlotMethod,\n SlotProps,\n} from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { useEffect, useState } from 'preact/hooks';\n\nexport interface TermsAndConditionsProps {\n active?: boolean;\n slots?: {\n Agreements?: SlotProps<{\n appendAgreement: SlotMethod<{\n name: string;\n mode: AgreementMode;\n translationId?: string;\n text?: string;\n }>;\n }>;\n };\n}\n\nexport const TermsAndConditions: Container<TermsAndConditionsProps> = ({\n active = true,\n slots,\n ...props\n}) => {\n const [isInitialized, setIsInitialized] = useState(false);\n const [error, setError] = useState<string>('');\n\n const { errorMessage } = useText({\n errorMessage: 'Checkout.TermsAndConditions.error',\n });\n\n const disabledViaConfig = state.config?.agreementsEnabled === false;\n\n const handleChange = () => {\n setError('');\n };\n\n const handleInvalid = () => {\n setError(errorMessage);\n };\n\n useEffect(() => {\n if (!active || disabledViaConfig) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n setIsInitialized(true);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n () => {\n setIsInitialized(true);\n },\n { eager: true }\n );\n return () => {\n onCheckoutInit?.off();\n };\n }, [active, disabledViaConfig]);\n\n return (\n <TermsAndConditionsComponent\n {...props}\n agreements={\n <Slot\n context={{\n appendAgreement(callback) {\n this._registerMethod((...attrs) => {\n const _agreement = callback(...attrs);\n\n if (!_agreement) return;\n\n const { mode, name, text, translationId } = _agreement;\n\n if (!text && !translationId) {\n console.warn(\n `The agreement ${name} is misconfigured. Please provide a text or a translationId.`\n );\n return;\n }\n\n const label = text ? (\n <Markup html={text} />\n ) : (\n <MarkupText id={translationId!} />\n );\n\n const agreement = (\n <Checkbox\n checked={mode === AgreementMode.AUTO}\n label={label}\n name={name}\n required={true}\n onChange={handleChange}\n onInvalid={handleInvalid}\n />\n );\n\n this._setProps((prev: any) => ({\n children: [...(prev.children || []), agreement],\n }));\n });\n },\n }}\n name=\"Agreements\"\n slot={slots?.Agreements}\n />\n }\n error={error}\n initialized={isInitialized}\n visible={active && !disabledViaConfig}\n />\n );\n};\n"],"names":["Markup","html","sanitizedHtml","DOMPurify","TermsAndConditionsSkeleton","jsx","Skeleton","SkeletonRow","TermsAndConditionsComponent","className","agreements","error","props","jsxs","classes","VComponent","TermsAndConditions","WithConditionals","active","slots","isInitialized","setIsInitialized","useState","setError","errorMessage","useText","disabledViaConfig","_a","state","handleChange","handleInvalid","useEffect","getLatestCheckoutUpdate","onCheckoutInit","events","Slot","callback","attrs","_agreement","mode","name","text","translationId","label","MarkupText","agreement","Checkbox","AgreementMode","prev"],"mappings":"u5BAwBO,MAAMA,EAAyC,CAAC,CAAE,KAAAC,KAAW,CAC5D,MAAAC,EAAgBC,EAAU,SAASF,EAAM,CAAE,SAAU,CAAC,QAAQ,EAAG,EACnE,OAAAC,IAAkB,GAAW,OAEzB,OAAK,CAAA,wBAAyB,CAAE,OAAQA,GAAiB,CACnE,ECTaE,EAAgD,IAEzDC,EAACC,EAAA,CACC,UAAU,yCACV,cAAY,yCAEZ,WAACC,EAAY,CAAA,UAAW,GAAM,KAAK,QAAQ,QAAQ,KAAM,CAAA,CAAA,CAC3D,ECGEC,EAEF,CAAC,CAAE,UAAAC,EAAW,WAAAC,EAAY,MAAAC,EAAO,GAAGC,KAEpCP,EAAC,MAAA,CACC,UAAU,gCACV,cAAY,gCAEZ,SAAAQ,EAAC,OAAA,CACE,GAAGD,EACJ,WAAU,GACV,UAAWE,EAAQ,CAAC,sCAAuCL,CAAS,CAAC,EACrE,cAAY,qCACZ,KAAK,sCAEJ,SAAA,CACCC,GAAAL,EAACU,EAAA,CACC,UAAWD,EAAQ,CAAC,2CAA2C,CAAC,EAChE,cAAY,2CACZ,KAAMJ,CAAA,CACR,EAGDC,GACCN,EAAC,MAAA,CACC,UAAU,uCACV,cAAY,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W,CAAA,GAAIF,CAAgB,CAAA,EAG5BG,EACJxC,EAACyC,EAAA,CACC,QAASP,IAASQ,EAAc,KAChC,MAAAJ,EACA,KAAAH,EACA,SAAU,GACV,SAAUX,EACV,UAAWC,CAAA,CACb,EAGG,KAAA,UAAWkB,IAAe,CAC7B,SAAU,CAAC,GAAIA,EAAK,UAAY,GAAKH,CAAS,CAAA,EAC9C,CAAA,CACH,CAAA,CAEL,EACA,KAAK,aACL,KAAM1B,GAAA,YAAAA,EAAO,UAAA,CACf,EAEF,MAAAR,EACA,YAAaS,EACb,QAASF,GAAU,CAACQ,CAAA,CACtB,CAEJ"}
|
package/containers/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
+
export * from './AddressValidation';
|
|
17
18
|
export * from './BillToShippingAddress';
|
|
18
19
|
export * from './EstimateShipping';
|
|
19
20
|
export * from './LoginForm';
|
|
@@ -21,7 +22,9 @@ export * from './MergedCartBanner';
|
|
|
21
22
|
export * from './OutOfStock';
|
|
22
23
|
export * from './PaymentMethods';
|
|
23
24
|
export * from './PlaceOrder';
|
|
25
|
+
export * from './PurchaseOrder';
|
|
24
26
|
export * from './ServerError';
|
|
25
27
|
export * from './ShippingMethods';
|
|
26
28
|
export * from './TermsAndConditions';
|
|
29
|
+
export * from './PaymentOnAccount';
|
|
27
30
|
//# sourceMappingURL=index.d.ts.map
|
package/data/models/address.d.ts
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { Country, Region, ShippingMethod } from '.';
|
|
1
|
+
import { Country, CustomAttribute, Region, ShippingMethod } from '.';
|
|
2
2
|
|
|
3
3
|
export interface Address {
|
|
4
4
|
city: string;
|
|
5
5
|
company?: string;
|
|
6
6
|
country: Country;
|
|
7
|
+
customAttributes: CustomAttribute[];
|
|
8
|
+
fax?: string;
|
|
7
9
|
firstName: string;
|
|
10
|
+
id?: number;
|
|
8
11
|
lastName: string;
|
|
12
|
+
middleName?: string;
|
|
9
13
|
postCode?: string;
|
|
14
|
+
prefix?: string;
|
|
10
15
|
region?: Region;
|
|
11
16
|
street: string[];
|
|
17
|
+
suffix?: string;
|
|
12
18
|
telephone?: string;
|
|
19
|
+
uid: string;
|
|
20
|
+
vatId?: string;
|
|
13
21
|
}
|
|
14
22
|
export interface ShippingAddress extends Address {
|
|
15
23
|
availableShippingMethods?: ShippingMethod[];
|
package/data/models/api.d.ts
CHANGED
|
@@ -1,33 +1,46 @@
|
|
|
1
|
-
import { CustomAttribute } from '
|
|
1
|
+
import { CustomAttribute } from '.';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface ExtensibleInput {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
6
|
+
export interface AddressInput {
|
|
4
7
|
city: string;
|
|
5
8
|
company?: string;
|
|
6
9
|
countryCode: string;
|
|
7
|
-
customAttributes
|
|
10
|
+
customAttributes?: CustomAttribute[];
|
|
11
|
+
fax?: string;
|
|
8
12
|
firstName: string;
|
|
9
13
|
lastName: string;
|
|
14
|
+
middleName?: string;
|
|
10
15
|
postcode?: string;
|
|
16
|
+
prefix?: string;
|
|
11
17
|
region?: string;
|
|
12
18
|
regionId?: number;
|
|
13
19
|
saveInAddressBook?: boolean;
|
|
14
20
|
street: string[];
|
|
21
|
+
suffix?: string;
|
|
15
22
|
telephone?: string;
|
|
16
23
|
vatId?: string;
|
|
17
|
-
prefix?: string;
|
|
18
|
-
suffix?: string;
|
|
19
|
-
middleName?: string;
|
|
20
|
-
fax?: string;
|
|
21
24
|
}
|
|
22
|
-
export interface ShippingAddressInput {
|
|
23
|
-
address?:
|
|
25
|
+
export interface ShippingAddressInput extends ExtensibleInput {
|
|
26
|
+
address?: AddressInput;
|
|
24
27
|
customerAddressId?: number;
|
|
28
|
+
customerAddressUid?: string;
|
|
25
29
|
pickupLocationCode?: string;
|
|
26
30
|
}
|
|
27
31
|
export interface BillingAddressInput {
|
|
28
|
-
address?:
|
|
32
|
+
address?: AddressInput;
|
|
29
33
|
customerAddressId?: number;
|
|
34
|
+
customerAddressUid?: string;
|
|
30
35
|
sameAsShipping?: boolean;
|
|
31
36
|
useForShipping?: boolean;
|
|
32
37
|
}
|
|
38
|
+
export interface PaymentMethodInput extends ExtensibleInput {
|
|
39
|
+
code: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ShippingMethodInput extends ExtensibleInput {
|
|
42
|
+
carrierCode: string;
|
|
43
|
+
methodCode: string;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
33
46
|
//# sourceMappingURL=api.d.ts.map
|
package/data/models/cart.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import { Address,
|
|
1
|
+
import { Address, PaymentMethod, ShippingAddress } from '.';
|
|
2
2
|
|
|
3
3
|
export interface CartAddress extends Address {
|
|
4
|
-
customAttributes: CustomAttribute[];
|
|
5
|
-
fax?: string;
|
|
6
|
-
id?: number;
|
|
7
|
-
middleName?: string;
|
|
8
|
-
prefix?: string;
|
|
9
|
-
suffix?: string;
|
|
10
|
-
vatId?: string;
|
|
11
4
|
}
|
|
12
5
|
export type CartShippingAddress = CartAddress & ShippingAddress & {
|
|
13
6
|
sameAsBilling?: boolean;
|
package/data/models/index.d.ts
CHANGED
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
+
export type AdditionalData = Record<string, unknown>;
|
|
17
18
|
export type PaymentMethod = {
|
|
18
19
|
code: string;
|
|
19
20
|
title: string;
|
|
21
|
+
additionalData?: AdditionalData;
|
|
20
22
|
};
|
|
21
23
|
//# sourceMappingURL=payment-method.d.ts.map
|
package/data/models/quote.d.ts
CHANGED
package/data/models/values.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { PaymentMethod, ShippingMethod } from '.';
|
|
|
2
2
|
|
|
3
3
|
export interface ValuesModel {
|
|
4
4
|
email: string;
|
|
5
|
-
isBillToShipping: boolean;
|
|
5
|
+
isBillToShipping: boolean | undefined;
|
|
6
6
|
selectedPaymentMethod: PaymentMethod | null;
|
|
7
7
|
selectedShippingMethod: ShippingMethod | null;
|
|
8
8
|
}
|
|
@@ -14,8 +14,11 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
+
export * from './transform-api';
|
|
18
|
+
export * from './transform-custom-attributes';
|
|
17
19
|
export * from './transform-cart';
|
|
18
20
|
export * from './transform-cart-address';
|
|
21
|
+
export * from './transform-company-credit';
|
|
19
22
|
export * from './transform-quote-address';
|
|
20
23
|
export * from './transform-checkout-agreements';
|
|
21
24
|
export * from './transform-country';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BillingAddressInput as BillingAddressInputModel, PaymentMethodInput as PaymentMethodInputModel, ShippingAddressInput as ShippingAddressInputModel, ShippingMethodInput as ShippingMethodInputModel } from '../models/api';
|
|
2
|
+
import { BillingAddressInput, NegotiableQuoteBillingAddressInput, NegotiableQuotePaymentMethodInput, NegotiableQuoteShippingAddressInput, PaymentMethodInput, ShippingAddressInput, ShippingMethodInput } from '../../__generated__/types';
|
|
3
|
+
|
|
4
|
+
export declare function transformPaymentMethodInputModelToCartInput({ code, ...additionalData }: PaymentMethodInputModel): PaymentMethodInput;
|
|
5
|
+
export declare function transformPaymentMethodInputModelToQuoteInput({ code, ...additionalData }: PaymentMethodInputModel): NegotiableQuotePaymentMethodInput;
|
|
6
|
+
export declare const transformShippingMethodInput: (input: ShippingMethodInputModel | ShippingMethodInput) => ShippingMethodInput;
|
|
7
|
+
export declare function transformShippingMethodsInputModel(input: Array<ShippingMethodInputModel | ShippingMethodInput>): Array<ShippingMethodInput>;
|
|
8
|
+
export declare function transformShippingAddressInputModelToCartInput(input: ShippingAddressInputModel): ShippingAddressInput;
|
|
9
|
+
export declare function transformShippingAddressInputModelToQuoteInput(input: ShippingAddressInputModel): NegotiableQuoteShippingAddressInput;
|
|
10
|
+
export declare function transformBillingAddressInputModelToCartInput(input: BillingAddressInputModel): BillingAddressInput;
|
|
11
|
+
export declare function transformBillingAddressInputModelToQuoteInput(input: BillingAddressInputModel): NegotiableQuoteBillingAddressInput;
|
|
12
|
+
//# sourceMappingURL=transform-api.d.ts.map
|
|
@@ -1,48 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AddressInput as AddressInputModel, CartAddress as CartAddressModel, CartShippingAddress as CartShippingAddressModel } from '../models';
|
|
2
|
+
import { GetCartQuery } from '../../__generated__/types';
|
|
3
3
|
|
|
4
4
|
type ShippingAddresses = NonNullable<GetCartQuery['cart']>['shipping_addresses'];
|
|
5
5
|
type CartShippingAddress = ShippingAddresses[0];
|
|
6
|
-
type NonNullableShippingAddress = NonNullable<CartShippingAddress>;
|
|
7
6
|
type CartBillingAddress = NonNullable<GetCartQuery['cart']>['billing_address'];
|
|
8
|
-
type NonNullableBillingAddress = NonNullable<CartBillingAddress>;
|
|
9
|
-
type CustomAttributes = NonNullableShippingAddress['custom_attributes'] | NonNullableBillingAddress['custom_attributes'];
|
|
10
|
-
export declare const transformCustomAttributes: (data: CustomAttributes) => CustomAttributeModel[];
|
|
11
7
|
declare const transformCartBillingAddress: (data: CartBillingAddress) => CartAddressModel | undefined;
|
|
12
8
|
declare const transformCartShippingAddress: (data: ({
|
|
13
9
|
__typename?: "ShippingCartAddress" | undefined;
|
|
14
|
-
|
|
10
|
+
city: string;
|
|
11
|
+
company?: string | null | undefined;
|
|
12
|
+
fax?: string | null | undefined;
|
|
15
13
|
firstname: string;
|
|
14
|
+
id?: number | null | undefined;
|
|
16
15
|
lastname: string;
|
|
17
|
-
|
|
18
|
-
street: (string | null)[];
|
|
19
|
-
city: string;
|
|
16
|
+
middlename?: string | null | undefined;
|
|
20
17
|
postcode?: string | null | undefined;
|
|
21
|
-
vat_id?: string | null | undefined;
|
|
22
|
-
telephone?: string | null | undefined;
|
|
23
|
-
same_as_billing: boolean;
|
|
24
18
|
prefix?: string | null | undefined;
|
|
19
|
+
same_as_billing: boolean;
|
|
20
|
+
street: (string | null)[];
|
|
25
21
|
suffix?: string | null | undefined;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
__typename?: "CartAddressRegion" | undefined;
|
|
30
|
-
region_id?: number | null | undefined;
|
|
31
|
-
code?: string | null | undefined;
|
|
32
|
-
label?: string | null | undefined;
|
|
33
|
-
} | null | undefined;
|
|
34
|
-
country: {
|
|
35
|
-
__typename?: "CartAddressCountry" | undefined;
|
|
36
|
-
code: string;
|
|
37
|
-
label: string;
|
|
38
|
-
};
|
|
39
|
-
custom_attributes: ({
|
|
40
|
-
__typename?: "AttributeSelectedOptions" | undefined;
|
|
41
|
-
} | {
|
|
42
|
-
__typename?: "AttributeValue" | undefined;
|
|
43
|
-
code: string;
|
|
44
|
-
value: string;
|
|
45
|
-
} | null)[];
|
|
22
|
+
telephone?: string | null | undefined;
|
|
23
|
+
uid: string;
|
|
24
|
+
vat_id?: string | null | undefined;
|
|
46
25
|
available_shipping_methods?: ({
|
|
47
26
|
__typename?: "AvailableShippingMethod" | undefined;
|
|
48
27
|
carrier_code: string;
|
|
@@ -66,6 +45,26 @@ declare const transformCartShippingAddress: (data: ({
|
|
|
66
45
|
currency?: import('../../__generated__/types').CurrencyEnum | null | undefined;
|
|
67
46
|
};
|
|
68
47
|
} | null)[] | null | undefined;
|
|
48
|
+
country: {
|
|
49
|
+
__typename?: "CartAddressCountry" | undefined;
|
|
50
|
+
code: string;
|
|
51
|
+
label: string;
|
|
52
|
+
};
|
|
53
|
+
custom_attributes: ({
|
|
54
|
+
__typename?: "AttributeFile" | undefined;
|
|
55
|
+
} | {
|
|
56
|
+
__typename?: "AttributeSelectedOptions" | undefined;
|
|
57
|
+
} | {
|
|
58
|
+
__typename?: "AttributeValue" | undefined;
|
|
59
|
+
code: string;
|
|
60
|
+
value: string;
|
|
61
|
+
} | null)[];
|
|
62
|
+
region?: {
|
|
63
|
+
__typename?: "CartAddressRegion" | undefined;
|
|
64
|
+
region_id?: number | null | undefined;
|
|
65
|
+
code?: string | null | undefined;
|
|
66
|
+
label?: string | null | undefined;
|
|
67
|
+
} | null | undefined;
|
|
69
68
|
selected_shipping_method?: {
|
|
70
69
|
__typename?: "SelectedShippingMethod" | undefined;
|
|
71
70
|
carrier_code: string;
|
|
@@ -89,6 +88,6 @@ declare const transformCartShippingAddress: (data: ({
|
|
|
89
88
|
};
|
|
90
89
|
} | null | undefined;
|
|
91
90
|
} | null)[]) => CartShippingAddressModel[];
|
|
92
|
-
declare const
|
|
93
|
-
export { CartBillingAddress, CartShippingAddress,
|
|
91
|
+
declare const transformAddressToCartAddressInput: <T extends CartAddressModel>(address?: T | null | undefined) => AddressInputModel | undefined;
|
|
92
|
+
export { CartBillingAddress, CartShippingAddress, transformAddressToCartAddressInput, transformCartBillingAddress, transformCartShippingAddress, };
|
|
94
93
|
//# sourceMappingURL=transform-cart-address.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CompanyCredit as CompanyCreditModel } from '../models';
|
|
2
|
+
import { CompanyCredit as CompanyCreditType } from '../../__generated__/types';
|
|
3
|
+
|
|
4
|
+
type OptionalCompanyCredit = CompanyCreditType | null | undefined;
|
|
5
|
+
declare const transformCompanyCredit: (data: OptionalCompanyCredit) => CompanyCreditModel | null;
|
|
6
|
+
export { transformCompanyCredit };
|
|
7
|
+
//# sourceMappingURL=transform-company-credit.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CustomAttribute as CustomAttributeModel } from '../models/custom-attribute';
|
|
2
|
+
import { AttributeValue } from '../../__generated__/types';
|
|
3
|
+
|
|
4
|
+
export declare const transformCustomAttributes: (data: Array<AttributeValue | any | null> | null | undefined) => CustomAttributeModel[];
|
|
5
|
+
//# sourceMappingURL=transform-custom-attributes.d.ts.map
|
|
@@ -7,24 +7,19 @@ type QuoteBillingAddress = NonNullable<GetNegotiableQuoteQuery['negotiableQuote'
|
|
|
7
7
|
declare const transformQuoteBillingAddress: (data: QuoteBillingAddress) => AddressModel | undefined;
|
|
8
8
|
declare const transformQuoteShippingAddress: (data: ({
|
|
9
9
|
__typename?: "NegotiableQuoteShippingAddress" | undefined;
|
|
10
|
+
city: string;
|
|
11
|
+
company?: string | null | undefined;
|
|
12
|
+
fax?: string | null | undefined;
|
|
10
13
|
firstname: string;
|
|
11
14
|
lastname: string;
|
|
12
|
-
|
|
13
|
-
street: (string | null)[];
|
|
14
|
-
city: string;
|
|
15
|
+
middlename?: string | null | undefined;
|
|
15
16
|
postcode?: string | null | undefined;
|
|
17
|
+
prefix?: string | null | undefined;
|
|
18
|
+
street: (string | null)[];
|
|
19
|
+
suffix?: string | null | undefined;
|
|
16
20
|
telephone?: string | null | undefined;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
region_id?: number | null | undefined;
|
|
20
|
-
code?: string | null | undefined;
|
|
21
|
-
label?: string | null | undefined;
|
|
22
|
-
} | null | undefined;
|
|
23
|
-
country: {
|
|
24
|
-
__typename?: "NegotiableQuoteAddressCountry" | undefined;
|
|
25
|
-
code: string;
|
|
26
|
-
label: string;
|
|
27
|
-
};
|
|
21
|
+
uid: string;
|
|
22
|
+
vat_id?: string | null | undefined;
|
|
28
23
|
available_shipping_methods?: ({
|
|
29
24
|
__typename?: "AvailableShippingMethod" | undefined;
|
|
30
25
|
carrier_code: string;
|
|
@@ -48,6 +43,26 @@ declare const transformQuoteShippingAddress: (data: ({
|
|
|
48
43
|
currency?: import('../../__generated__/types').CurrencyEnum | null | undefined;
|
|
49
44
|
};
|
|
50
45
|
} | null)[] | null | undefined;
|
|
46
|
+
country: {
|
|
47
|
+
__typename?: "NegotiableQuoteAddressCountry" | undefined;
|
|
48
|
+
code: string;
|
|
49
|
+
label: string;
|
|
50
|
+
};
|
|
51
|
+
custom_attributes?: ({
|
|
52
|
+
__typename?: "AttributeFile" | undefined;
|
|
53
|
+
} | {
|
|
54
|
+
__typename?: "AttributeSelectedOptions" | undefined;
|
|
55
|
+
} | {
|
|
56
|
+
__typename?: "AttributeValue" | undefined;
|
|
57
|
+
code: string;
|
|
58
|
+
value: string;
|
|
59
|
+
} | null)[] | null | undefined;
|
|
60
|
+
region?: {
|
|
61
|
+
__typename?: "NegotiableQuoteAddressRegion" | undefined;
|
|
62
|
+
region_id?: number | null | undefined;
|
|
63
|
+
code?: string | null | undefined;
|
|
64
|
+
label?: string | null | undefined;
|
|
65
|
+
} | null | undefined;
|
|
51
66
|
selected_shipping_method?: {
|
|
52
67
|
__typename?: "SelectedShippingMethod" | undefined;
|
|
53
68
|
carrier_code: string;
|