@dropins/storefront-checkout 2.2.0-alpha2 → 2.2.0-alpha4
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/graphql/getCompanyCredit.graphql.d.ts +1 -1
- package/chunks/PaymentOnAccount2.js +1 -1
- package/chunks/PaymentOnAccount2.js.map +1 -1
- package/chunks/PurchaseOrder.js +1 -1
- package/chunks/PurchaseOrder.js.map +1 -1
- package/chunks/classifiers.js +1 -1
- package/chunks/classifiers.js.map +1 -1
- package/chunks/dom.js +1 -1
- package/chunks/dom.js.map +1 -1
- package/chunks/getCompanyCredit.js +1 -0
- package/chunks/getCompanyCredit.js.map +1 -1
- package/chunks/render.js +1 -1
- package/chunks/render.js.map +1 -1
- package/chunks/synchronizeCheckout.js +6 -6
- package/chunks/synchronizeCheckout.js.map +1 -1
- package/chunks/validation.js +4 -0
- package/chunks/validation.js.map +1 -0
- package/components/PaymentOnAccount/PaymentOnAccount.d.ts +2 -2
- package/components/PurchaseOrder/PurchaseOrder.d.ts +3 -1
- package/containers/LoginForm.js +1 -1
- package/containers/LoginForm.js.map +1 -1
- package/containers/PaymentMethods/handlers.d.ts +4 -1
- package/containers/PaymentMethods/index.d.ts +1 -0
- package/containers/PaymentMethods.js +1 -1
- package/containers/PaymentMethods.js.map +1 -1
- package/containers/PaymentOnAccount.js +1 -1
- package/containers/PurchaseOrder.js +1 -1
- package/i18n/en_US.json.d.ts +5 -3
- package/lib/errors/classifiers.d.ts +2 -1
- package/lib/utils/dom.d.ts +2 -0
- package/lib/utils/forms.d.ts +8 -2
- package/lib/utils.js +1 -1
- package/lib/utils.js.map +1 -1
- package/lib/validation.d.ts +6 -0
- package/package.json +1 -1
- package/types/index.d.ts +1 -1
- package/types/storefront.d.ts +224 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymentMethods.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/Wallet.svg","/@dropins/storefront-checkout/src/components/PaymentMethods/PaymentMethodsSkeleton.tsx","/@dropins/storefront-checkout/src/components/PaymentMethods/PaymentMethods.tsx","../../node_modules/@adobe-commerce/elsie/src/lib/debounce.ts","/@dropins/storefront-checkout/src/containers/PaymentMethods/handlers.tsx","/@dropins/storefront-checkout/src/containers/PaymentMethods/PaymentMethods.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgWallet = (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: \"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M19.35 11.64H14.04V14.81H19.35V11.64Z\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M17.9304 11.64V8.25H15.1504\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }));\nexport default SvgWallet;\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 PaymentMethodsSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"payment-methods-skeleton\">\n <SkeletonRow size=\"medium\" variant=\"heading\" />\n <SkeletonRow size=\"medium\" variant=\"empty\" />\n <SkeletonRow fullWidth={true} size=\"xlarge\" />\n <SkeletonRow fullWidth={true} size=\"xlarge\" />\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/PaymentMethods/PaymentMethods.css';\nimport { PaymentMethodsSkeleton } from '@/checkout/components/PaymentMethods/PaymentMethodsSkeleton';\nimport { PaymentMethodConfig } from '@/checkout/containers';\nimport { PaymentMethod } from '@/checkout/data/models/payment-method';\nimport { scrollToElement } from '@/checkout/lib';\nimport { UIComponentType } from '@/checkout/types';\nimport {\n Icon,\n IllustratedMessage,\n InLineAlert,\n RadioButton,\n ToggleButton,\n} from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Wallet } from '@adobe-commerce/elsie/icons';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes, useEffect, useRef } from 'preact/compat';\n\ninterface ExtendedPaymentMethod extends PaymentMethodConfig, PaymentMethod {}\n\nexport interface PaymentMethodsProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n error?: string | null;\n busy?: boolean;\n onDismissError?: () => void;\n onSelectionChange?: (value: PaymentMethod) => void;\n options?: ExtendedPaymentMethod[];\n paymentMethodContent?: VNode;\n selection: PaymentMethod | null;\n title?: VNode;\n UIComponentType?: UIComponentType;\n}\n\ninterface PaymentOptionProps {\n UIComponentType?: UIComponentType;\n busy?: boolean;\n code: string;\n icon?: string;\n onSelectionChange: (value: PaymentMethod) => void;\n selected: boolean;\n title: string;\n}\n\nconst PaymentOption: FunctionComponent<PaymentOptionProps> = ({\n UIComponentType = 'ToggleButton',\n busy,\n code,\n icon,\n onSelectionChange,\n selected,\n title,\n}) => {\n const commonProps = {\n busy,\n className: 'checkout-payment-methods__method',\n label: title,\n name: 'payment-method',\n onChange: () => onSelectionChange({ code, title }),\n value: code,\n };\n\n return UIComponentType === 'ToggleButton' ? (\n <ToggleButton\n {...commonProps}\n // @ts-ignore\n icon={icon ? <Icon source={icon} /> : undefined}\n selected={selected}\n />\n ) : (\n <RadioButton {...commonProps} checked={selected} icon={icon ?? undefined} />\n );\n};\n\nconst PaymentMethodsComponent: FunctionComponent<PaymentMethodsProps> = ({\n className,\n error = null,\n busy = false,\n onDismissError,\n onSelectionChange = () => {},\n options,\n paymentMethodContent,\n selection,\n title,\n UIComponentType,\n}) => {\n const translations = useText({\n EmptyState: 'Checkout.PaymentMethods.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 return (\n <div\n className={classes(['checkout-payment-methods', className])}\n data-testid=\"checkout-payment-methods\"\n >\n {title && (\n <VComponent className=\"checkout-payment-methods__title\" node={title} />\n )}\n\n {!busy && options!.length === 0 && (\n <IllustratedMessage\n data-testid=\"checkout-payment-methods-empty\"\n icon={<Icon source={Wallet} />}\n message={<p>{translations.EmptyState}</p>}\n />\n )}\n\n <div\n className={classes([\n 'checkout-payment-methods__wrapper',\n ['checkout-payment-methods__wrapper--busy', busy],\n ])}\n data-testid=\"checkout-payment-methods-wrapper\"\n >\n <div\n className={classes([\n 'checkout-payment-methods__methods',\n ['checkout-payment-methods--full-width', options!.length % 2 !== 0],\n ])}\n >\n {options?.map((method) => (\n <PaymentOption\n key={method.code}\n UIComponentType={UIComponentType}\n busy={busy}\n code={method.code}\n icon={method.icon}\n selected={selection?.code === method.code}\n title={method.displayLabel ?? true ? method.title : ''}\n onSelectionChange={onSelectionChange}\n />\n ))}\n </div>\n\n {paymentMethodContent && (\n <div className=\"checkout-payment-methods__content\">\n {paymentMethodContent}\n </div>\n )}\n </div>\n\n {hasError && (\n <div\n ref={errorRef}\n className=\"checkout-payment-methods__error\"\n data-testid=\"checkout-payment-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 PaymentMethods = WithConditionals(\n PaymentMethodsComponent,\n PaymentMethodsSkeleton\n);\n","/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport const debounce = (fn: Function, ms: number) => {\n let timeoutId: ReturnType<typeof setTimeout>;\n return function (this: any, ...args: any[]) {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => fn.apply(this, args), ms);\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { setPaymentMethod } from '@/checkout/api/index';\nimport {\n PaymentMethodConfig,\n PaymentOnAccount,\n PurchaseOrder,\n} from '@/checkout/containers';\nimport { render as Checkout } from '@/checkout/render/render';\nimport { debounce } from '@adobe-commerce/elsie/lib/debounce';\nimport { Container } from '@adobe-commerce/elsie/lib/types';\n\nconst createOrderRefHandler = (\n Container: Container<{\n initialReferenceNumber: string;\n onReferenceNumberChange: (refNumber: string) => void;\n }>,\n code: string\n): PaymentMethodConfig => ({\n enabled: true,\n autoSync: false,\n render: (ctx) => {\n const initialReferenceNumber = String(\n ctx.additionalData?.purchase_order_number ?? ''\n );\n const $wrapper = document.createElement('div');\n\n const onReferenceNumberChange = debounce((refNumber: string) => {\n setPaymentMethod({\n code,\n purchase_order_number: refNumber,\n }).catch(console.error);\n }, 1000);\n\n Checkout.render(Container, {\n initialReferenceNumber,\n onReferenceNumberChange,\n })($wrapper);\n\n ctx.replaceHTML($wrapper);\n },\n});\n\nexport enum PaymentMethods {\n PaymentOnAccount = 'companycredit',\n PurchaseOrder = 'purchaseorder',\n}\n\nexport const defaultHandlers = {\n [PaymentMethods.PaymentOnAccount]: createOrderRefHandler(\n PaymentOnAccount,\n PaymentMethods.PaymentOnAccount\n ),\n [PaymentMethods.PurchaseOrder]: createOrderRefHandler(\n PurchaseOrder,\n PaymentMethods.PurchaseOrder\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 { setPaymentMethod } from '@/checkout/api';\nimport { PaymentMethods as PaymentMethodsComponent } from '@/checkout/components/PaymentMethods/PaymentMethods';\nimport { Cart } from '@/checkout/data/models/cart';\nimport {\n AdditionalData,\n PaymentMethod,\n} from '@/checkout/data/models/payment-method';\nimport { NegotiableQuote } from '@/checkout/data/models/quote';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingUpdates,\n hasShippingAddress,\n isVirtualCart,\n notifyValues,\n state,\n} from '@/checkout/lib';\nimport { TitleProps, UIComponentType } from '@/checkout/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport {\n Container,\n deepmerge,\n Slot,\n SlotProps,\n} 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';\nimport { defaultHandlers } from './handlers';\n\ninterface RenderContext {\n additionalData?: AdditionalData;\n cartId: string;\n replaceHTML: (domElement: HTMLElement) => void;\n setAdditionalData: (data: AdditionalData) => void;\n}\n\nexport interface PaymentMethodConfig {\n autoSync?: boolean;\n displayLabel?: boolean;\n enabled?: boolean;\n icon?: string;\n render?: SlotProps<RenderContext>;\n}\n\nexport interface PaymentMethodHandlers {\n [code: string]: PaymentMethodConfig;\n}\n\ninterface CartSyncError {\n method: PaymentMethod;\n error: Error;\n}\n\nexport interface PaymentMethodsProps\n extends HTMLAttributes<HTMLDivElement>,\n TitleProps {\n slots?: {\n Methods?: PaymentMethodHandlers;\n } & TitleProps['slots'];\n UIComponentType?: UIComponentType;\n active?: boolean;\n autoSync?: boolean;\n onCartSyncError?: (error: CartSyncError) => void;\n onSelectionChange?: (method: PaymentMethod) => void;\n}\n\nfunction isValidSelection(\n selection: PaymentMethod | null,\n options: PaymentMethod[]\n) {\n if (!selection) return false;\n return options.some((option) => option.code === selection.code);\n}\n\nfunction isEqual(a: PaymentMethod | null, b: PaymentMethod | null) {\n if (!a || !b) return false;\n return a.code === b.code;\n}\n\nfunction isValidPaymentMethod(method: PaymentMethod | null) {\n if (!method) return false;\n return !!method.code && !!method.title;\n}\n\nexport const PaymentMethods: Container<PaymentMethodsProps> = ({\n UIComponentType = 'ToggleButton',\n active = true,\n autoSync = true,\n displayTitle = true,\n slots,\n onCartSyncError,\n onSelectionChange,\n}) => {\n const [error, setError] = useState<string | null>(null);\n const [isInitialized, setIsInitialized] = useState(false);\n const [selection, setSelection] = useState<PaymentMethod | null>(null);\n const [options, setOptions] = useState<PaymentMethod[]>([]);\n const isBusy = hasPendingUpdates.value;\n\n const availableHandlers = useMemo(() => {\n const customHandlers = slots?.Methods ?? {};\n return deepmerge(defaultHandlers, customHandlers);\n }, [slots?.Methods]);\n\n const enabledOptions = options\n .filter((method) => {\n return availableHandlers?.[method.code]?.enabled !== false;\n })\n .map((method) => {\n const slotMethod = availableHandlers?.[method.code] || {};\n\n return {\n ...method,\n ...slotMethod,\n };\n });\n\n const { cartSyncError, defaultTitle } = useText({\n cartSyncError: 'Checkout.PaymentMethods.cartSyncError',\n defaultTitle: 'Checkout.PaymentMethods.title',\n });\n\n const setAdditionalData = useCallback((additionalData: AdditionalData) => {\n setSelection((prev) => {\n if (!prev) return prev;\n return { ...prev, additionalData };\n });\n\n const currentSelection = getValue('selectedPaymentMethod');\n\n if (!currentSelection) return;\n\n notifyValues({\n selectedPaymentMethod: {\n ...currentSelection,\n additionalData,\n },\n });\n }, []);\n\n const handleDismissError = useCallback(() => {\n setError(null);\n }, []);\n\n const setUserSelection = useCallback((selection: PaymentMethod | null) => {\n setError(null);\n setSelection(selection);\n notifyValues({ selectedPaymentMethod: selection });\n }, []);\n\n const setUserSelectionOnCart = useCallback(\n async (selection: PaymentMethod, fallback?: PaymentMethod | null) => {\n const canSetUserSelectionOnCart = isVirtualCart() || hasShippingAddress();\n if (!canSetUserSelectionOnCart) return;\n\n const methodConfig = availableHandlers?.[selection.code];\n const shouldAutoSync = methodConfig?.autoSync ?? autoSync;\n\n if (!shouldAutoSync) return;\n\n setPaymentMethod({ code: selection.code }).catch((error) => {\n setUserSelection(fallback ?? null);\n onCartSyncError?.({ method: selection, error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [\n availableHandlers,\n autoSync,\n setUserSelection,\n onCartSyncError,\n cartSyncError,\n ]\n );\n\n const handleSelectionChange = useCallback(\n async (selection: PaymentMethod) => {\n const prevSelection = getValue('selectedPaymentMethod');\n\n setUserSelection(selection);\n onSelectionChange?.(selection);\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\n if (isEmptyCart) {\n setUserSelection(null);\n setOptions([]);\n return;\n }\n\n const availableOptions = data.availablePaymentMethods ?? [];\n setOptions(availableOptions);\n\n if (availableOptions.length === 0) {\n setUserSelection(null);\n return;\n }\n\n const cartSelection = data.selectedPaymentMethod ?? null;\n const hasCartSelection = isValidPaymentMethod(cartSelection);\n const userSelection = getValue('selectedPaymentMethod');\n const isAvailable = isValidSelection(userSelection, availableOptions);\n const haveSameSelection = isEqual(userSelection, cartSelection);\n\n // User has valid selection that differs from cart\n if (userSelection && isAvailable && !haveSameSelection) {\n setUserSelectionOnCart(userSelection, cartSelection);\n return;\n }\n\n // User has invalid selection but cart has valid selection\n if (\n (!userSelection || !isAvailable) &&\n hasCartSelection &&\n isValidSelection(cartSelection, availableOptions)\n ) {\n setUserSelection(cartSelection);\n return;\n }\n\n // Neither user nor cart has valid selection (or both selections are unavailable)\n if (\n (!userSelection || !isAvailable) &&\n (!hasCartSelection ||\n !isValidSelection(cartSelection, availableOptions))\n ) {\n const newSelection = availableOptions[0];\n setUserSelection(newSelection);\n setUserSelectionOnCart(newSelection);\n }\n },\n [setUserSelection, setUserSelectionOnCart]\n );\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n setIsInitialized(true);\n // When component becomes active, restore key state so handleCheckoutData can work properly\n const userSelection = getValue('selectedPaymentMethod');\n if (userSelection) {\n setSelection(userSelection);\n }\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n (data: Cart | NegotiableQuote | null) => {\n setIsInitialized(true);\n handleCheckoutData(data);\n },\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 const selectionConfig = availableHandlers[selection?.code || ''];\n\n const paymentMethodContent = selectionConfig ? (\n <Slot\n key={selection?.code}\n context={{\n additionalData: selection?.additionalData,\n cartId: state.cartId ?? '',\n replaceHTML(domElement: HTMLElement) {\n this.replaceWith(domElement);\n },\n setAdditionalData,\n }}\n name=\"PaymentMethodContent\"\n slot={selectionConfig.render}\n />\n ) : undefined;\n\n const titleContent = useMemo(() => {\n if (!displayTitle) return undefined;\n\n return (\n <Slot name=\"checkout-payment-methods-title\" slot={slots?.Title}>\n <h2>{defaultTitle}</h2>\n </Slot>\n );\n }, [displayTitle, slots?.Title, defaultTitle]);\n\n return (\n <PaymentMethodsComponent\n UIComponentType={UIComponentType}\n busy={isBusy}\n error={error}\n initialized={isInitialized}\n options={enabledOptions}\n paymentMethodContent={paymentMethodContent}\n selection={selection}\n title={titleContent}\n visible={active}\n onDismissError={handleDismissError}\n onSelectionChange={handleSelectionChange}\n />\n );\n};\n"],"names":["SvgWallet","props","React","PaymentMethodsSkeleton","jsxs","Skeleton","jsx","SkeletonRow","PaymentOption","UIComponentType","busy","code","icon","onSelectionChange","selected","title","commonProps","ToggleButton","Icon","RadioButton","PaymentMethodsComponent","className","error","onDismissError","options","paymentMethodContent","selection","translations","useText","hasError","errorRef","useRef","useEffect","scrollToElement","classes","VComponent","IllustratedMessage","Wallet","method","InLineAlert","PaymentMethods","WithConditionals","debounce","fn","ms","timeoutId","args","createOrderRefHandler","Container","ctx","initialReferenceNumber","_a","$wrapper","onReferenceNumberChange","refNumber","setPaymentMethod","Checkout","defaultHandlers","PaymentOnAccount","PurchaseOrder","isValidSelection","option","isEqual","a","b","isValidPaymentMethod","active","autoSync","displayTitle","slots","onCartSyncError","setError","useState","isInitialized","setIsInitialized","setSelection","setOptions","isBusy","hasPendingUpdates","availableHandlers","useMemo","customHandlers","deepmerge","enabledOptions","slotMethod","cartSyncError","defaultTitle","setAdditionalData","useCallback","additionalData","prev","currentSelection","getValue","notifyValues","handleDismissError","setUserSelection","setUserSelectionOnCart","fallback","isVirtualCart","hasShippingAddress","methodConfig","handleSelectionChange","prevSelection","handleCheckoutData","data","availableOptions","cartSelection","hasCartSelection","userSelection","isAvailable","haveSameSelection","newSelection","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","events","onCheckoutUpdated","selectionConfig","Slot","state","domElement","titleContent"],"mappings":"2mDACA,MAAMA,GAAaC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAO,EAAkBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,gJAAiJ,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,wCAAyC,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAS,CAAA,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,8BAA+B,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAAE,CAAC,ECmBn5BC,GAA4C,IAErDC,EAACC,GAAS,CAAA,cAAY,2BACpB,SAAA,CAAAC,EAACC,EAAY,CAAA,KAAK,SAAS,QAAQ,UAAU,EAC5CD,EAAAC,EAAA,CAAY,KAAK,SAAS,QAAQ,QAAQ,EAC1CD,EAAAC,EAAA,CAAY,UAAW,GAAM,KAAK,SAAS,EAC3CD,EAAAC,EAAA,CA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ules/@adobe-commerce/elsie/src/icons/Wallet.svg","/@dropins/storefront-checkout/src/components/PaymentMethods/PaymentMethodsSkeleton.tsx","/@dropins/storefront-checkout/src/components/PaymentMethods/PaymentMethods.tsx","../../node_modules/@adobe-commerce/elsie/src/lib/debounce.ts","/@dropins/storefront-checkout/src/containers/PaymentMethods/handlers.tsx","/@dropins/storefront-checkout/src/containers/PaymentMethods/PaymentMethods.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgWallet = (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: \"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M19.35 11.64H14.04V14.81H19.35V11.64Z\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M17.9304 11.64V8.25H15.1504\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }));\nexport default SvgWallet;\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 PaymentMethodsSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"payment-methods-skeleton\">\n <SkeletonRow size=\"medium\" variant=\"heading\" />\n <SkeletonRow size=\"medium\" variant=\"empty\" />\n <SkeletonRow fullWidth={true} size=\"xlarge\" />\n <SkeletonRow fullWidth={true} size=\"xlarge\" />\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/PaymentMethods/PaymentMethods.css';\nimport { PaymentMethodsSkeleton } from '@/checkout/components/PaymentMethods/PaymentMethodsSkeleton';\nimport { PaymentMethodConfig } from '@/checkout/containers';\nimport { PaymentMethod } from '@/checkout/data/models/payment-method';\nimport { scrollToElement } from '@/checkout/lib';\nimport { UIComponentType } from '@/checkout/types';\nimport {\n Icon,\n IllustratedMessage,\n InLineAlert,\n RadioButton,\n ToggleButton,\n} from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Wallet } from '@adobe-commerce/elsie/icons';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes, useEffect, useRef } from 'preact/compat';\n\ninterface ExtendedPaymentMethod extends PaymentMethodConfig, PaymentMethod {}\n\nexport interface PaymentMethodsProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n error?: string | null;\n busy?: boolean;\n onDismissError?: () => void;\n onSelectionChange?: (value: PaymentMethod) => void;\n options?: ExtendedPaymentMethod[];\n paymentMethodContent?: VNode;\n selection: PaymentMethod | null;\n title?: VNode;\n UIComponentType?: UIComponentType;\n}\n\ninterface PaymentOptionProps {\n UIComponentType?: UIComponentType;\n busy?: boolean;\n code: string;\n icon?: string;\n onSelectionChange: (value: PaymentMethod) => void;\n selected: boolean;\n title: string;\n}\n\nconst PaymentOption: FunctionComponent<PaymentOptionProps> = ({\n UIComponentType = 'ToggleButton',\n busy,\n code,\n icon,\n onSelectionChange,\n selected,\n title,\n}) => {\n const commonProps = {\n busy,\n className: 'checkout-payment-methods__method',\n label: title,\n name: 'payment-method',\n onChange: () => onSelectionChange({ code, title }),\n value: code,\n };\n\n return UIComponentType === 'ToggleButton' ? (\n <ToggleButton\n {...commonProps}\n // @ts-ignore\n icon={icon ? <Icon source={icon} /> : undefined}\n selected={selected}\n />\n ) : (\n <RadioButton {...commonProps} checked={selected} icon={icon ?? undefined} />\n );\n};\n\nconst PaymentMethodsComponent: FunctionComponent<PaymentMethodsProps> = ({\n className,\n error = null,\n busy = false,\n onDismissError,\n onSelectionChange = () => {},\n options,\n paymentMethodContent,\n selection,\n title,\n UIComponentType,\n}) => {\n const translations = useText({\n EmptyState: 'Checkout.PaymentMethods.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 return (\n <div\n className={classes(['checkout-payment-methods', className])}\n data-testid=\"checkout-payment-methods\"\n >\n {title && (\n <VComponent className=\"checkout-payment-methods__title\" node={title} />\n )}\n\n {!busy && options!.length === 0 && (\n <IllustratedMessage\n data-testid=\"checkout-payment-methods-empty\"\n icon={<Icon source={Wallet} />}\n message={<p>{translations.EmptyState}</p>}\n />\n )}\n\n <div\n className={classes([\n 'checkout-payment-methods__wrapper',\n ['checkout-payment-methods__wrapper--busy', busy],\n ])}\n data-testid=\"checkout-payment-methods-wrapper\"\n >\n <div\n className={classes([\n 'checkout-payment-methods__methods',\n ['checkout-payment-methods--full-width', options!.length % 2 !== 0],\n ])}\n >\n {options?.map((method) => (\n <PaymentOption\n key={method.code}\n UIComponentType={UIComponentType}\n busy={busy}\n code={method.code}\n icon={method.icon}\n selected={selection?.code === method.code}\n title={method.displayLabel ?? true ? method.title : ''}\n onSelectionChange={onSelectionChange}\n />\n ))}\n </div>\n\n {paymentMethodContent && (\n <div className=\"checkout-payment-methods__content\">\n {paymentMethodContent}\n </div>\n )}\n </div>\n\n {hasError && (\n <div\n ref={errorRef}\n className=\"checkout-payment-methods__error\"\n data-testid=\"checkout-payment-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 PaymentMethods = WithConditionals(\n PaymentMethodsComponent,\n PaymentMethodsSkeleton\n);\n","/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport const debounce = (fn: Function, ms: number) => {\n let timeoutId: ReturnType<typeof setTimeout>;\n return function (this: any, ...args: any[]) {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => fn.apply(this, args), ms);\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { setPaymentMethod } from '@/checkout/api';\nimport {\n PaymentMethodConfig,\n PaymentOnAccount,\n PurchaseOrder,\n} from '@/checkout/containers';\nimport { validateNotEmpty } from '@/checkout/lib/validation';\nimport { render as Checkout } from '@/checkout/render/render';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { debounce } from '@adobe-commerce/elsie/lib/debounce';\n\ninterface HandlerConfig {\n Container: Container<any>;\n autoSync: boolean;\n formName?: string;\n validateRefNumber: boolean;\n}\n\nexport enum HandlerCode {\n PaymentOnAccount = 'companycredit',\n PurchaseOrder = 'purchaseorder',\n}\n\nconst HANDLERS_CONFIG: Record<HandlerCode, HandlerConfig> = {\n [HandlerCode.PaymentOnAccount]: {\n Container: PaymentOnAccount,\n autoSync: true,\n formName: 'payment-on-account',\n validateRefNumber: false,\n },\n [HandlerCode.PurchaseOrder]: {\n Container: PurchaseOrder,\n autoSync: false,\n formName: 'purchase-order',\n validateRefNumber: true,\n },\n} as const;\n\n// Cache for debounced handlers to prevent memory leaks\nconst debouncedHandlers = new Map<string, ReturnType<typeof debounce>>();\n\nexport const handleRefNumberChange = (code: string, isRequired: boolean) => {\n const key = `${code}-${isRequired}`;\n\n if (!debouncedHandlers.has(key)) {\n const debouncedFn = debounce(async (refNumber: string) => {\n if (!isRequired || validateNotEmpty(refNumber)) {\n try {\n await setPaymentMethod({\n code,\n purchase_order_number: refNumber,\n });\n } catch (error) {\n console.error(`Failed to set payment method for ${code}:`, error);\n }\n }\n }, 1000);\n\n debouncedHandlers.set(key, debouncedFn);\n }\n\n return debouncedHandlers.get(key)!;\n};\n\nconst handlerCache: Partial<Record<HandlerCode, PaymentMethodConfig>> = {};\n\nexport const resetHandlersCache = () => {\n Object.keys(handlerCache).forEach((key) => {\n delete handlerCache[key as HandlerCode];\n });\n\n debouncedHandlers.clear();\n};\n\nexport const createHandler = (code: HandlerCode): PaymentMethodConfig => {\n if (!(code in HANDLERS_CONFIG)) {\n throw new Error(`Invalid handler code: ${code}`);\n }\n\n if (handlerCache[code]) {\n return handlerCache[code] as PaymentMethodConfig;\n }\n\n const config = HANDLERS_CONFIG[code];\n\n const { autoSync, Container, formName, validateRefNumber } = config;\n\n const handler: PaymentMethodConfig = {\n enabled: true,\n autoSync,\n render: (ctx) => {\n const initialReferenceNumber = String(\n ctx.additionalData?.purchase_order_number ?? ''\n );\n\n const $wrapper = document.createElement('div');\n\n Checkout.render(Container, {\n name: formName,\n initialReferenceNumber,\n onReferenceNumberChange: handleRefNumberChange(code, validateRefNumber),\n })($wrapper);\n\n ctx.replaceHTML($wrapper);\n },\n };\n\n handlerCache[code] = handler;\n\n return handler;\n};\n\nexport const defaultHandlers = {\n [HandlerCode.PaymentOnAccount]: createHandler(HandlerCode.PaymentOnAccount),\n [HandlerCode.PurchaseOrder]: createHandler(HandlerCode.PurchaseOrder),\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 { setPaymentMethod } from '@/checkout/api';\nimport { PaymentMethods as PaymentMethodsComponent } from '@/checkout/components/PaymentMethods/PaymentMethods';\nimport { Cart } from '@/checkout/data/models/cart';\nimport {\n AdditionalData,\n PaymentMethod\n} from '@/checkout/data/models/payment-method';\nimport { NegotiableQuote } from '@/checkout/data/models/quote';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingUpdates,\n hasShippingAddress,\n isVirtualCart,\n notifyValues,\n state\n} from '@/checkout/lib';\nimport { TitleProps, UIComponentType } from '@/checkout/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport {\n Container,\n deepmerge,\n Slot,\n SlotProps\n} 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';\nimport { defaultHandlers } from './handlers';\n\ninterface RenderContext {\n additionalData?: AdditionalData;\n cartId: string;\n replaceHTML: (domElement: HTMLElement) => void;\n setAdditionalData: (data: AdditionalData) => void;\n}\n\nexport interface PaymentMethodConfig {\n autoSync?: boolean;\n displayLabel?: boolean;\n enabled?: boolean;\n icon?: string;\n render?: SlotProps<RenderContext>;\n}\n\nexport interface PaymentMethodHandlers {\n [code: string]: PaymentMethodConfig;\n}\n\ninterface CartSyncError {\n method: PaymentMethod;\n error: Error;\n}\n\ntype EnabledOption = PaymentMethod & PaymentMethodConfig;\n\nexport interface PaymentMethodsProps\n extends HTMLAttributes<HTMLDivElement>,\n TitleProps {\n slots?: {\n Methods?: PaymentMethodHandlers;\n } & TitleProps['slots'];\n UIComponentType?: UIComponentType;\n active?: boolean;\n autoSync?: boolean;\n onCartSyncError?: (error: CartSyncError) => void;\n onSelectionChange?: (method: PaymentMethod) => void;\n}\n\nfunction isAvailable(\n selection: PaymentMethod | null,\n options: PaymentMethod[]\n) {\n if (!selection) return false;\n return options.some((option) => option.code === selection.code);\n}\n\nfunction isEqual(a: PaymentMethod | null, b: PaymentMethod | null) {\n if (!a || !b) return false;\n return a.code === b.code;\n}\n\nfunction isValid(method: PaymentMethod | null) {\n if (!method) return false;\n return !!method.code && !!method.title;\n}\n\nexport const PaymentMethods: Container<PaymentMethodsProps> = ({\n UIComponentType = 'ToggleButton',\n active = true,\n autoSync = true,\n displayTitle = true,\n slots,\n onCartSyncError,\n onSelectionChange,\n}) => {\n const [error, setError] = useState<string | null>(null);\n const [isInitialized, setIsInitialized] = useState(false);\n const [selection, setSelection] = useState<PaymentMethod | null>(null);\n const [options, setOptions] = useState<PaymentMethod[]>([]);\n const isBusy = hasPendingUpdates.value;\n\n const { cartSyncError, defaultTitle } = useText({\n cartSyncError: 'Checkout.PaymentMethods.cartSyncError',\n defaultTitle: 'Checkout.PaymentMethods.title',\n });\n\n const availableHandlers = useMemo(() => {\n const customHandlers = slots?.Methods ?? {};\n return deepmerge(defaultHandlers, customHandlers);\n }, [slots?.Methods]);\n\n const enabledOptions: EnabledOption[] = useMemo(\n () =>\n options\n .filter((method) => availableHandlers?.[method.code]?.enabled !== false)\n .map((method) => {\n const slotMethod = availableHandlers?.[method.code] || {};\n\n return {\n ...method,\n ...slotMethod,\n };\n }),\n [options, availableHandlers]\n );\n\n const setAdditionalData = useCallback((additionalData: AdditionalData) => {\n setSelection((prev) => {\n if (!prev) return prev;\n return { ...prev, additionalData };\n });\n\n const currentSelection = getValue('selectedPaymentMethod');\n\n if (!currentSelection) return;\n\n notifyValues({\n selectedPaymentMethod: {\n ...currentSelection,\n additionalData,\n },\n });\n }, []);\n\n const handleDismissError = useCallback(() => {\n setError(null);\n }, []);\n\n const setUserSelection = useCallback((selection: PaymentMethod | null) => {\n setError(null);\n setSelection(selection);\n notifyValues({ selectedPaymentMethod: selection });\n }, []);\n\n const setUserSelectionOnCart = useCallback(\n async (selection: PaymentMethod, fallback?: PaymentMethod | null) => {\n const canSetUserSelectionOnCart = isVirtualCart() || hasShippingAddress();\n if (!canSetUserSelectionOnCart) return;\n\n const methodConfig = availableHandlers?.[selection.code];\n const shouldAutoSync = methodConfig?.autoSync ?? autoSync;\n\n if (!shouldAutoSync) return;\n\n setPaymentMethod({ code: selection.code }).catch((error) => {\n setUserSelection(fallback ?? null);\n onCartSyncError?.({ method: selection, error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [\n availableHandlers,\n autoSync,\n setUserSelection,\n onCartSyncError,\n cartSyncError,\n ]\n );\n\n const handleSelectionChange = useCallback(\n async (selection: PaymentMethod) => {\n const prevSelection = getValue('selectedPaymentMethod');\n\n setUserSelection(selection);\n onSelectionChange?.(selection);\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\n if (isEmptyCart) {\n setUserSelection(null);\n setOptions([]);\n return;\n }\n\n const availableOptions = data.availablePaymentMethods ?? [];\n setOptions(availableOptions);\n\n if (availableOptions.length === 0) {\n setUserSelection(null);\n return;\n }\n\n const cartSelection = data.selectedPaymentMethod ?? null;\n const hasCartSelection = isValid(cartSelection);\n const userSelection = getValue('selectedPaymentMethod');\n const isUserSelectionAvailable = isAvailable(userSelection, availableOptions);\n const haveSameSelection = isEqual(userSelection, cartSelection);\n\n // User has valid selection that differs from cart\n if (userSelection && isUserSelectionAvailable && !haveSameSelection) {\n setUserSelectionOnCart(userSelection, cartSelection);\n return;\n }\n\n // User has invalid selection but cart has valid selection\n if (\n (!userSelection || !isUserSelectionAvailable) &&\n hasCartSelection &&\n isAvailable(cartSelection, availableOptions)\n ) {\n setUserSelection(cartSelection);\n return;\n }\n\n // Neither user nor cart has valid selection (or both selections are unavailable)\n if (\n (!userSelection || !isUserSelectionAvailable) &&\n (!hasCartSelection ||\n !isAvailable(cartSelection, availableOptions))\n ) {\n const newSelection = availableOptions[0];\n setUserSelection(newSelection);\n setUserSelectionOnCart(newSelection);\n }\n },\n [setUserSelection, setUserSelectionOnCart]\n );\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n setIsInitialized(true);\n // When component becomes active, restore key state so handleCheckoutData can work properly\n const userSelection = getValue('selectedPaymentMethod');\n if (userSelection) {\n setSelection(userSelection);\n }\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n (data: Cart | NegotiableQuote | null) => {\n setIsInitialized(true);\n handleCheckoutData(data);\n },\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 // When the current selection is disabled, this effect automatically selects the first available method\n useEffect(() => {\n if (enabledOptions.length === 0) return;\n\n const isEnabled = isAvailable(selection, enabledOptions);\n if (isEnabled) return;\n\n const firstAvailableOption = enabledOptions[0];\n const { code, title, additionalData } = firstAvailableOption;\n const selectedMethod = { code, title, additionalData };\n setUserSelection(selectedMethod);\n setUserSelectionOnCart(selectedMethod);\n }, [enabledOptions, selection, setUserSelection, setUserSelectionOnCart]);\n\n const titleContent = useMemo(() => {\n if (!displayTitle) return undefined;\n\n return (\n <Slot name=\"checkout-payment-methods-title\" slot={slots?.Title}>\n <h2>{defaultTitle}</h2>\n </Slot>\n );\n }, [displayTitle, slots?.Title, defaultTitle]);\n\n const paymentMethodContent = useMemo(() => {\n const slot = enabledOptions.find((method) => isEqual(method, selection))?.render;\n if (!slot) return undefined;\n\n return (\n <Slot\n key={selection!.code}\n context={{\n additionalData: selection!.additionalData,\n cartId: state.cartId ?? '',\n replaceHTML(domElement: HTMLElement) {\n this.replaceWith(domElement);\n },\n setAdditionalData,\n }}\n name=\"PaymentMethodContent\"\n slot={slot}\n />\n );\n\n }, [enabledOptions, selection, setAdditionalData])\n\n return (\n <PaymentMethodsComponent\n UIComponentType={UIComponentType}\n busy={isBusy}\n error={error}\n initialized={isInitialized}\n options={enabledOptions}\n paymentMethodContent={paymentMethodContent}\n selection={selection}\n title={titleContent}\n visible={active}\n onDismissError={handleDismissError}\n onSelectionChange={handleSelectionChange}\n />\n );\n};\n"],"names":["SvgWallet","props","React","PaymentMethodsSkeleton","jsxs","Skeleton","jsx","SkeletonRow","PaymentOption","UIComponentType","busy","code","icon","onSelectionChange","selected","title","commonProps","ToggleButton","Icon","RadioButton","PaymentMethodsComponent","className","error","onDismissError","options","paymentMethodContent","selection","translations","useText","hasError","errorRef","useRef","useEffect","scrollToElement","classes","VComponent","IllustratedMessage","Wallet","method","InLineAlert","PaymentMethods","WithConditionals","debounce","fn","ms","timeoutId","args","HandlerCode","HANDLERS_CONFIG","PaymentOnAccount","PurchaseOrder","debouncedHandlers","handleRefNumberChange","isRequired","key","debouncedFn","refNumber","validateNotEmpty","setPaymentMethod","handlerCache","resetHandlersCache","createHandler","config","autoSync","Container","formName","validateRefNumber","handler","ctx","initialReferenceNumber","_a","$wrapper","Checkout","defaultHandlers","isAvailable","option","isEqual","a","b","isValid","active","displayTitle","slots","onCartSyncError","setError","useState","isInitialized","setIsInitialized","setSelection","setOptions","isBusy","hasPendingUpdates","cartSyncError","defaultTitle","availableHandlers","useMemo","customHandlers","deepmerge","enabledOptions","slotMethod","setAdditionalData","useCallback","additionalData","prev","currentSelection","getValue","notifyValues","handleDismissError","setUserSelection","setUserSelectionOnCart","fallback","isVirtualCart","hasShippingAddress","methodConfig","handleSelectionChange","prevSelection","handleCheckoutData","data","availableOptions","cartSelection","hasCartSelection","userSelection","isUserSelectionAvailable","haveSameSelection","newSelection","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","events","onCheckoutUpdated","firstAvailableOption","selectedMethod","titleContent","Slot","slot","state","domElement"],"mappings":"wpDACA,MAAMA,GAAaC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAO,EAAkBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,gJAAiJ,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,wCAAyC,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAS,CAAA,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,8BAA+B,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAAE,CAAC,ECmBn5BC,GAA4C,IAErDC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4C,EAA6D,OACtE,GAACgE,EAGH,OAAAhI,EAAC+H,EAAA,CAEC,QAAS,CACP,eAAgB3G,EAAW,eAC3B,OAAQ6G,GAAM,QAAU,GACxB,YAAYC,EAAyB,CACnC,KAAK,YAAYA,CAAU,CAC7B,EACA,kBAAApC,CACF,EACA,KAAK,uBACL,KAAAkC,CAAA,EAVK5G,EAAW,IAWlB,CAGD,EAAA,CAACwE,EAAgBxE,EAAW0E,CAAiB,CAAC,EAG/C,OAAA9F,EAACc,GAAA,CACC,gBAAiBX,EACjB,KAAMiF,EACN,MAAApE,EACA,YAAagE,EACb,QAASY,EACT,qBAAAzE,GACA,UAAAC,EACA,MAAO0G,GACP,QAASpD,EACT,eAAgB2B,GAChB,kBAAmBO,EAAA,CACrB,CAEJ","x_google_ignoreList":[0,3]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{P as d,P as l}from"../chunks/PaymentOnAccount2.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";import"@dropins/tools/lib.js"
|
|
3
|
+
import{P as d,P as l}from"../chunks/PaymentOnAccount2.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/preact-compat.js";import"../chunks/ConditionalWrapper.js";/* empty css */import"@dropins/tools/components.js";import"@dropins/tools/lib.js";import"@dropins/tools/i18n.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getCompanyCredit.js";export{d as PaymentOnAccount,l as default};
|
|
4
4
|
//# sourceMappingURL=PaymentOnAccount.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{P as
|
|
3
|
+
import{P as b,P as g}from"../chunks/PurchaseOrder.js";import"@dropins/tools/preact-jsx-runtime.js";import"../chunks/TermsAndConditions.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";/* empty css */import"../chunks/fetch-graphql.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/validation.js";import"@dropins/tools/preact-compat.js";/* empty css *//* empty css */import"@dropins/tools/i18n.js";/* empty css */import"@dropins/tools/preact-hooks.js";export{b as PurchaseOrder,g as default};
|
|
4
4
|
//# sourceMappingURL=PurchaseOrder.js.map
|
package/i18n/en_US.json.d.ts
CHANGED
|
@@ -76,9 +76,10 @@ declare const _default: {
|
|
|
76
76
|
"exceedLimitError": "Payment On Account cannot be used for this order because your order amount exceeds your credit amount."
|
|
77
77
|
},
|
|
78
78
|
"PurchaseOrder": {
|
|
79
|
+
"missingReferenceNumberError": "Reference number is required",
|
|
80
|
+
"referenceNumberHint": "",
|
|
79
81
|
"referenceNumberLabel": "Custom Reference Number",
|
|
80
|
-
"referenceNumberPlaceholder": "Enter custom reference number"
|
|
81
|
-
"referenceNumberHint": ""
|
|
82
|
+
"referenceNumberPlaceholder": "Enter custom reference number"
|
|
82
83
|
},
|
|
83
84
|
"PlaceOrder": {
|
|
84
85
|
"button": "Place Order"
|
|
@@ -87,7 +88,8 @@ declare const _default: {
|
|
|
87
88
|
"button": "Try again",
|
|
88
89
|
"contactSupport": "If you continue to have issues, please contact support.",
|
|
89
90
|
"title": "We were unable to process your order",
|
|
90
|
-
"unexpected": "An unexpected error occurred while processing your order. Please try again later."
|
|
91
|
+
"unexpected": "An unexpected error occurred while processing your order. Please try again later.",
|
|
92
|
+
"permissionDenied": "You do not have permission to complete checkout. Please contact your administrator for assistance."
|
|
91
93
|
},
|
|
92
94
|
"Quote": {
|
|
93
95
|
"permissionDenied": "You do not have permission to checkout with this quote.",
|
|
@@ -21,7 +21,8 @@ export declare enum ErrorCodes {
|
|
|
21
21
|
UNAUTHENTICATED = "UNAUTHENTICATED",
|
|
22
22
|
UNKNOWN_ERROR = "UNKNOWN_ERROR",
|
|
23
23
|
QUOTE_DATA_ERROR = "QUOTE_DATA_ERROR",
|
|
24
|
-
QUOTE_PERMISSION_DENIED = "QUOTE_PERMISSION_DENIED"
|
|
24
|
+
QUOTE_PERMISSION_DENIED = "QUOTE_PERMISSION_DENIED",
|
|
25
|
+
PERMISSION_DENIED = "PERMISSION_DENIED"
|
|
25
26
|
}
|
|
26
27
|
export interface ErrorClassifier {
|
|
27
28
|
/**
|
package/lib/utils/dom.d.ts
CHANGED
|
@@ -14,5 +14,7 @@
|
|
|
14
14
|
* is strictly forbidden unless prior written permission is obtained
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
|
+
export declare function getParentContainer(element: HTMLElement): HTMLElement | null;
|
|
17
18
|
export declare function scrollToElement(element: HTMLElement): void;
|
|
19
|
+
export declare function scrollToParentContainer(element: HTMLElement): void;
|
|
18
20
|
//# sourceMappingURL=dom.d.ts.map
|
package/lib/utils/forms.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { FormRef } from '../../types
|
|
1
|
+
import { FormRef } from '../../types';
|
|
2
2
|
import { RefObject } from 'preact';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type HTMLForm = {
|
|
5
|
+
name: string;
|
|
6
|
+
ref?: RefObject<FormRef>;
|
|
7
|
+
};
|
|
8
|
+
export declare function validateForm(form: HTMLForm, autoScrollOnError?: boolean): boolean;
|
|
9
|
+
export declare function validateForms(forms: HTMLForm[]): boolean;
|
|
10
|
+
export {};
|
|
5
11
|
//# sourceMappingURL=forms.d.ts.map
|
package/lib/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import"../chunks/fetch-graphql.js";import{s as l,e as C}from"../chunks/setShippingAddress.js";import{debounce as
|
|
3
|
+
import"../chunks/fetch-graphql.js";import{s as l,e as C}from"../chunks/setShippingAddress.js";import{debounce as g}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import{s as y}from"../chunks/setBillingAddress.js";import{b as K,c as L,g as Q,a as W,i as X}from"../chunks/events.js";import{a as A}from"../chunks/dom.js";import{g as Z,s as B}from"../chunks/dom.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/transform-shipping-estimate.js";import"../chunks/transform-shipping-methods.js";import"../chunks/values.js";import"../chunks/synchronizeCheckout.js";import"../fragments.js";import"../chunks/classifiers.js";import"../chunks/guards.js";import"../chunks/events2.js";let f=0;function D({type:e="shipping",debounceMs:t=0,placeOrderBtn:r}){const i=e==="shipping"?l:y,o=g(s=>{f+=1,i(s).catch(console.error).finally(()=>{f-=1,f===0&&(r==null||r.setProps(n=>({...n,disabled:!1})))})},t);return({data:s,isDataValid:n})=>{if(!n)return;r==null||r.setProps(c=>({...c,disabled:!0}));const u=d(s);o(u)}}function R({debounceMs:e=0}){let t={},r=!1;const i=g(o=>{var n,u,c,p;if(r)return;const s={country_code:o.countryCode,region_name:String(((n=o.region)==null?void 0:n.regionCode)||""),region_id:String(((u=o.region)==null?void 0:u.regionId)||""),zip:o.postcode};C({criteria:s}),t={countryCode:o.countryCode,regionCode:((c=o.region)==null?void 0:c.regionCode)||"",regionId:((p=o.region)==null?void 0:p.regionId)||"",postcode:o.postcode}},e);return({data:o,isDataValid:s})=>{var n,u;if(s){r=!0;return}t.countryCode===o.countryCode&&t.regionCode===(((n=o.region)==null?void 0:n.regionCode)||"")&&t.regionId===(((u=o.region)==null?void 0:u.regionId)||"")&&t.postcode===o.postcode||i(o)}}function h(e,t=!1){var n;const{name:r,ref:i}=e,o=document.forms.namedItem(r);if(!o||o.offsetParent===null)return!0;o.setAttribute("novalidate","");const s=((n=i==null?void 0:i.current)==null?void 0:n.handleValidationSubmit(!1))??o.checkValidity();return!s&&t&&A(o),s}function $(e){for(const t of e)if(!h(t,!0))return!1;return!0}function z(e){return document.createRange().createContextualFragment(e)}function U(e){return function(t){return e.querySelector(t)}}function m(e,t,r){if(!e||!r)return;const i=document.head.querySelector(`meta[${r}="${e}"]`);if(!t){i==null||i.remove();return}if(i)i.setAttribute("content",t);else{const o=document.createElement("meta");o.setAttribute(r,e),o.setAttribute("content",t),document.head.appendChild(o)}}function j(e){m("title",e,"name"),m("description",e,"name"),m("keywords",e,"name"),m("og:description",e,"property"),m("og:title",e,"property"),m("og:url",window.location.href,"property")}const d=e=>{var i,o,s;if(!(!(e!=null&&e.id)&&!(e!=null&&e.uid)))return{customerAddressId:e.id,customerAddressUid:e.uid};const r=(i=e.customAttributes)==null?void 0:i.map(({code:n,value:u})=>({code:n,value:String(u)}));return{address:{city:e.city,company:e==null?void 0:e.company,countryCode:e.countryCode,customAttributes:r,fax:e.fax,firstName:e.firstName,lastName:e.lastName,middleName:e.middleName,postcode:e.postcode,prefix:e.prefix,region:(o=e==null?void 0:e.region)==null?void 0:o.regionCode,regionId:(s=e==null?void 0:e.region)==null?void 0:s.regionId,street:e.street,suffix:e.suffix,telephone:e.telephone,vatId:e.vatId,saveInAddressBook:e.saveAddressBook}}},G=e=>{var t,r,i;return{city:e.city,company:e==null?void 0:e.company,countryCode:(t=e.country)==null?void 0:t.code,customAttributes:e.customAttributes,fax:e.fax,firstName:e.firstName,lastName:e.lastName,middleName:e.middleName,postcode:e.postCode,prefix:e.prefix,region:{regionCode:(r=e.region)==null?void 0:r.code,regionId:(i=e.region)==null?void 0:i.id},street:e.street,suffix:e.suffix,telephone:e.telephone,vatId:e.vatId}};export{z as createFragment,m as createMetaTag,U as createScopedSelector,R as estimateShippingCost,K as getCartAddress,L as getCartPaymentMethod,Q as getCartShippingMethod,Z as getParentContainer,W as isEmptyCart,X as isVirtualCart,B as scrollToElement,A as scrollToParentContainer,D as setAddressOnCart,j as setMetaTags,d as transformAddressFormValuesToAddressInput,G as transformCartAddressToFormValues,h as validateForm,$ as validateForms};
|
|
4
4
|
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["/@dropins/storefront-checkout/src/lib/utils/api.ts","/@dropins/storefront-checkout/src/lib/utils/forms.ts","/@dropins/storefront-checkout/src/lib/utils/fragments.ts","/@dropins/storefront-checkout/src/lib/utils/meta.ts","/@dropins/storefront-checkout/src/lib/utils/transformers.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 {\n estimateShippingMethods,\n setBillingAddress,\n setShippingAddress,\n} from '@/checkout/api';\nimport {\n BillingAddressInput,\n ShippingAddressInput,\n} from '@/checkout/data/models/api';\nimport { transformAddressFormValuesToAddressInput } from '@/checkout/lib/utils';\nimport { RenderAPI } from '@/checkout/types';\nimport { debounce } from '@adobe-commerce/elsie/lib';\n\ntype AddressFormChange = {\n data: Record<string, any>;\n isDataValid: boolean;\n};\n\nlet ongoingSetAddressCalls = 0;\n\nexport function setAddressOnCart({\n type = 'shipping',\n debounceMs = 0,\n placeOrderBtn,\n}: {\n type?: 'shipping' | 'billing';\n debounceMs?: number;\n placeOrderBtn?: RenderAPI;\n}) {\n const api = type === 'shipping' ? setShippingAddress : setBillingAddress;\n\n const debouncedApi = debounce(\n (address: ShippingAddressInput | BillingAddressInput) => {\n ongoingSetAddressCalls += 1;\n api(address)\n .catch(console.error)\n .finally(() => {\n ongoingSetAddressCalls -= 1;\n if (ongoingSetAddressCalls === 0) {\n placeOrderBtn?.setProps((prev) => ({ ...prev, disabled: false }));\n }\n });\n },\n debounceMs\n );\n\n return ({ data, isDataValid }: AddressFormChange) => {\n if (!isDataValid) return;\n placeOrderBtn?.setProps((prev) => ({ ...prev, disabled: true }));\n const address = transformAddressFormValuesToAddressInput(data);\n debouncedApi(address);\n };\n}\n\nexport function estimateShippingCost({ debounceMs = 0 }) {\n let prevEstimateShippingData: {\n countryCode?: string;\n regionCode?: string;\n regionId?: string;\n postcode?: string;\n } = {};\n\n let shouldCancelDebounce = false;\n\n const debouncedApi = debounce((data: Record<string, any>) => {\n if (shouldCancelDebounce) return;\n\n const estimateShippingInputCriteria = {\n country_code: data.countryCode,\n region_name: String(data.region?.regionCode || ''),\n region_id: String(data.region?.regionId || ''),\n zip: data.postcode,\n };\n\n estimateShippingMethods({ criteria: estimateShippingInputCriteria });\n\n prevEstimateShippingData = {\n countryCode: data.countryCode,\n regionCode: data.region?.regionCode || '',\n regionId: data.region?.regionId || '',\n postcode: data.postcode,\n };\n }, debounceMs);\n\n return ({ data, isDataValid }: AddressFormChange) => {\n if (isDataValid) {\n shouldCancelDebounce = true;\n return;\n }\n\n if (\n prevEstimateShippingData.countryCode === data.countryCode &&\n prevEstimateShippingData.regionCode === (data.region?.regionCode || '') &&\n prevEstimateShippingData.regionId === (data.region?.regionId || '') &&\n prevEstimateShippingData.postcode === data.postcode\n )\n return;\n\n debouncedApi(data);\n };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { FormRef } from '@/checkout/types/storefront-account';\nimport { RefObject } from 'preact';\n\nexport function validateForm(\n formName: string,\n formRef: RefObject<FormRef>\n): boolean {\n const formElement = document.forms.namedItem(formName);\n\n if (!formElement) {\n return true;\n }\n\n const isVisible = formElement && formElement.offsetParent !== null;\n if (!isVisible) {\n return true;\n }\n\n formElement.setAttribute('novalidate', '');\n\n if (formRef && formRef.current) {\n return formRef.current.handleValidationSubmit(false);\n }\n\n return formElement.checkValidity();\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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\nexport function createFragment(html: string): DocumentFragment {\n return document.createRange().createContextualFragment(html);\n}\n\nexport function createScopedSelector(\n fragment: DocumentFragment\n): (selector: string) => HTMLElement | null {\n return function (selector: string): HTMLElement | null {\n return fragment.querySelector(selector);\n };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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\nexport function createMetaTag(property: string, content: string, type: string) {\n if (!property || !type) {\n return;\n }\n\n const meta = document.head.querySelector<HTMLMetaElement>(\n `meta[${type}=\"${property}\"]`\n );\n\n if (!content) {\n meta?.remove();\n return;\n }\n\n if (meta) {\n meta.setAttribute('content', content);\n } else {\n const newMeta = document.createElement('meta');\n newMeta.setAttribute(type, property);\n newMeta.setAttribute('content', content);\n document.head.appendChild(newMeta);\n }\n}\n\nexport function setMetaTags(dropin: string) {\n createMetaTag('title', dropin, 'name');\n createMetaTag('description', dropin, 'name');\n createMetaTag('keywords', dropin, 'name');\n createMetaTag('og:description', dropin, 'property');\n createMetaTag('og:title', dropin, 'property');\n createMetaTag('og:url', window.location.href, 'property');\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 {\n BillingAddressInput,\n ShippingAddressInput,\n} from '@/checkout/data/models/api';\nimport { CartAddress } from '@/checkout/data/models/cart';\n\nexport const transformAddressFormValuesToAddressInput = (\n data: Record<string, any>\n): ShippingAddressInput | BillingAddressInput => {\n const isNewAddress = !data?.id && !data?.uid;\n\n if (!isNewAddress) {\n return {\n customerAddressId: data.id,\n customerAddressUid: data.uid,\n };\n }\n\n const customAttributes = data.customAttributes?.map(\n ({ code, value }: { code: string; value: unknown }) => ({\n code,\n value: String(value),\n })\n );\n\n return {\n address: {\n city: data.city,\n company: data?.company,\n countryCode: data.countryCode,\n customAttributes,\n fax: data.fax,\n firstName: data.firstName,\n lastName: data.lastName,\n middleName: data.middleName,\n postcode: data.postcode,\n prefix: data.prefix,\n region: data?.region?.regionCode,\n regionId: data?.region?.regionId,\n street: data.street,\n suffix: data.suffix,\n telephone: data.telephone,\n vatId: data.vatId,\n saveInAddressBook: data.saveAddressBook,\n },\n };\n};\n\nexport const transformCartAddressToFormValues = (\n address: CartAddress\n): Record<string, any> => {\n return {\n city: address.city,\n company: address?.company,\n countryCode: address.country?.code,\n customAttributes: address.customAttributes,\n fax: address.fax,\n firstName: address.firstName,\n lastName: address.lastName,\n middleName: address.middleName,\n postcode: address.postCode,\n prefix: address.prefix,\n region: {\n regionCode: address.region?.code,\n regionId: address.region?.id,\n },\n street: address.street,\n suffix: address.suffix,\n telephone: address.telephone,\n vatId: address.vatId,\n };\n};\n"],"names":["ongoingSetAddressCalls","setAddressOnCart","type","debounceMs","placeOrderBtn","api","setShippingAddress","setBillingAddress","debouncedApi","debounce","address","prev","data","isDataValid","transformAddressFormValuesToAddressInput","estimateShippingCost","prevEstimateShippingData","shouldCancelDebounce","estimateShippingInputCriteria","_a","_b","estimateShippingMethods","_c","_d","validateForm","formName","formRef","formElement","createFragment","html","createScopedSelector","fragment","selector","createMetaTag","property","content","meta","newMeta","setMetaTags","dropin","customAttributes","code","value","transformCartAddressToFormValues"],"mappings":"irBAmCA,IAAIA,EAAyB,EAEtB,SAASC,EAAiB,CAC/B,KAAAC,EAAO,WACP,WAAAC,EAAa,EACb,cAAAC,CACF,EAIG,CACK,MAAAC,EAAMH,IAAS,WAAaI,EAAqBC,EAEjDC,EAAeC,EAClBC,GAAwD,CAC7BV,GAAA,EAC1BK,EAAIK,CAAO,EACR,MAAM,QAAQ,KAAK,EACnB,QAAQ,IAAM,CACaV,GAAA,EACtBA,IAA2B,IACdI,GAAA,MAAAA,EAAA,SAAUO,IAAU,CAAE,GAAGA,EAAM,SAAU,MAC1D,CACD,CACL,EACAR,CACF,EAEA,MAAO,CAAC,CAAE,KAAAS,EAAM,YAAAC,KAAqC,CACnD,GAAI,CAACA,EAAa,OACHT,GAAA,MAAAA,EAAA,SAAUO,IAAU,CAAE,GAAGA,EAAM,SAAU,MAClD,MAAAD,EAAUI,EAAyCF,CAAI,EAC7DJ,EAAaE,CAAO,CACtB,CACF,CAEO,SAASK,EAAqB,CAAE,WAAAZ,EAAa,GAAK,CACvD,IAAIa,EAKA,CAAC,EAEDC,EAAuB,GAErB,MAAAT,EAAeC,EAAUG,GAA8B,aAC3D,GAAIK,EAAsB,OAE1B,MAAMC,EAAgC,CACpC,aAAcN,EAAK,YACnB,YAAa,SAAOO,EAAAP,EAAK,SAAL,YAAAO,EAAa,aAAc,EAAE,EACjD,UAAW,SAAOC,EAAAR,EAAK,SAAL,YAAAQ,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AA,CACL,KAAMA,EAAQ,KACd,QAASA,GAAA,YAAAA,EAAS,QAClB,aAAaS,EAAAT,EAAQ,UAAR,YAAAS,EAAiB,KAC9B,iBAAkBT,EAAQ,iBAC1B,IAAKA,EAAQ,IACb,UAAWA,EAAQ,UACnB,SAAUA,EAAQ,SAClB,WAAYA,EAAQ,WACpB,SAAUA,EAAQ,SAClB,OAAQA,EAAQ,OAChB,OAAQ,CACN,YAAYU,EAAAV,EAAQ,SAAR,YAAAU,EAAgB,KAC5B,UAAUE,EAAAZ,EAAQ,SAAR,YAAAY,EAAgB,EAC5B,EACA,OAAQZ,EAAQ,OAChB,OAAQA,EAAQ,OAChB,UAAWA,EAAQ,UACnB,MAAOA,EAAQ,KACjB,CACF"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["/@dropins/storefront-checkout/src/lib/utils/api.ts","/@dropins/storefront-checkout/src/lib/utils/forms.ts","/@dropins/storefront-checkout/src/lib/utils/fragments.ts","/@dropins/storefront-checkout/src/lib/utils/meta.ts","/@dropins/storefront-checkout/src/lib/utils/transformers.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 {\n estimateShippingMethods,\n setBillingAddress,\n setShippingAddress,\n} from '@/checkout/api';\nimport {\n BillingAddressInput,\n ShippingAddressInput,\n} from '@/checkout/data/models/api';\nimport { transformAddressFormValuesToAddressInput } from '@/checkout/lib/utils';\nimport { RenderAPI } from '@/checkout/types';\nimport { debounce } from '@adobe-commerce/elsie/lib';\n\ntype AddressFormChange = {\n data: Record<string, any>;\n isDataValid: boolean;\n};\n\nlet ongoingSetAddressCalls = 0;\n\nexport function setAddressOnCart({\n type = 'shipping',\n debounceMs = 0,\n placeOrderBtn,\n}: {\n type?: 'shipping' | 'billing';\n debounceMs?: number;\n placeOrderBtn?: RenderAPI;\n}) {\n const api = type === 'shipping' ? setShippingAddress : setBillingAddress;\n\n const debouncedApi = debounce(\n (address: ShippingAddressInput | BillingAddressInput) => {\n ongoingSetAddressCalls += 1;\n api(address)\n .catch(console.error)\n .finally(() => {\n ongoingSetAddressCalls -= 1;\n if (ongoingSetAddressCalls === 0) {\n placeOrderBtn?.setProps((prev) => ({ ...prev, disabled: false }));\n }\n });\n },\n debounceMs\n );\n\n return ({ data, isDataValid }: AddressFormChange) => {\n if (!isDataValid) return;\n placeOrderBtn?.setProps((prev) => ({ ...prev, disabled: true }));\n const address = transformAddressFormValuesToAddressInput(data);\n debouncedApi(address);\n };\n}\n\nexport function estimateShippingCost({ debounceMs = 0 }) {\n let prevEstimateShippingData: {\n countryCode?: string;\n regionCode?: string;\n regionId?: string;\n postcode?: string;\n } = {};\n\n let shouldCancelDebounce = false;\n\n const debouncedApi = debounce((data: Record<string, any>) => {\n if (shouldCancelDebounce) return;\n\n const estimateShippingInputCriteria = {\n country_code: data.countryCode,\n region_name: String(data.region?.regionCode || ''),\n region_id: String(data.region?.regionId || ''),\n zip: data.postcode,\n };\n\n estimateShippingMethods({ criteria: estimateShippingInputCriteria });\n\n prevEstimateShippingData = {\n countryCode: data.countryCode,\n regionCode: data.region?.regionCode || '',\n regionId: data.region?.regionId || '',\n postcode: data.postcode,\n };\n }, debounceMs);\n\n return ({ data, isDataValid }: AddressFormChange) => {\n if (isDataValid) {\n shouldCancelDebounce = true;\n return;\n }\n\n if (\n prevEstimateShippingData.countryCode === data.countryCode &&\n prevEstimateShippingData.regionCode === (data.region?.regionCode || '') &&\n prevEstimateShippingData.regionId === (data.region?.regionId || '') &&\n prevEstimateShippingData.postcode === data.postcode\n )\n return;\n\n debouncedApi(data);\n };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { scrollToParentContainer } from '@/checkout/lib/utils';\nimport { FormRef } from '@/checkout/types';\nimport { RefObject } from 'preact';\n\ntype HTMLForm = {\n name: string;\n ref?: RefObject<FormRef>;\n};\n\nexport function validateForm(\n form: HTMLForm,\n autoScrollOnError: boolean = false\n): boolean {\n const { name, ref } = form;\n const formElement = document.forms.namedItem(name);\n\n if (!formElement || formElement.offsetParent === null) {\n return true;\n }\n\n formElement.setAttribute('novalidate', '');\n\n const validationResult =\n ref?.current?.handleValidationSubmit(false) ?? formElement.checkValidity();\n\n if (!validationResult && autoScrollOnError) {\n scrollToParentContainer(formElement);\n }\n\n return validationResult;\n}\n\nexport function validateForms(forms: HTMLForm[]): boolean {\n for (const form of forms) {\n if (!validateForm(form, true)) {\n return false;\n }\n }\n return true;\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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\nexport function createFragment(html: string): DocumentFragment {\n return document.createRange().createContextualFragment(html);\n}\n\nexport function createScopedSelector(\n fragment: DocumentFragment\n): (selector: string) => HTMLElement | null {\n return function (selector: string): HTMLElement | null {\n return fragment.querySelector(selector);\n };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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\nexport function createMetaTag(property: string, content: string, type: string) {\n if (!property || !type) {\n return;\n }\n\n const meta = document.head.querySelector<HTMLMetaElement>(\n `meta[${type}=\"${property}\"]`\n );\n\n if (!content) {\n meta?.remove();\n return;\n }\n\n if (meta) {\n meta.setAttribute('content', content);\n } else {\n const newMeta = document.createElement('meta');\n newMeta.setAttribute(type, property);\n newMeta.setAttribute('content', content);\n document.head.appendChild(newMeta);\n }\n}\n\nexport function setMetaTags(dropin: string) {\n createMetaTag('title', dropin, 'name');\n createMetaTag('description', dropin, 'name');\n createMetaTag('keywords', dropin, 'name');\n createMetaTag('og:description', dropin, 'property');\n createMetaTag('og:title', dropin, 'property');\n createMetaTag('og:url', window.location.href, 'property');\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 {\n BillingAddressInput,\n ShippingAddressInput,\n} from '@/checkout/data/models/api';\nimport { CartAddress } from '@/checkout/data/models/cart';\n\nexport const transformAddressFormValuesToAddressInput = (\n data: Record<string, any>\n): ShippingAddressInput | BillingAddressInput => {\n const isNewAddress = !data?.id && !data?.uid;\n\n if (!isNewAddress) {\n return {\n customerAddressId: data.id,\n customerAddressUid: data.uid,\n };\n }\n\n const customAttributes = data.customAttributes?.map(\n ({ code, value }: { code: string; value: unknown }) => ({\n code,\n value: String(value),\n })\n );\n\n return {\n address: {\n city: data.city,\n company: data?.company,\n countryCode: data.countryCode,\n customAttributes,\n fax: data.fax,\n firstName: data.firstName,\n lastName: data.lastName,\n middleName: data.middleName,\n postcode: data.postcode,\n prefix: data.prefix,\n region: data?.region?.regionCode,\n regionId: data?.region?.regionId,\n street: data.street,\n suffix: data.suffix,\n telephone: data.telephone,\n vatId: data.vatId,\n saveInAddressBook: data.saveAddressBook,\n },\n };\n};\n\nexport const transformCartAddressToFormValues = (\n address: CartAddress\n): Record<string, any> => {\n return {\n city: address.city,\n company: address?.company,\n countryCode: address.country?.code,\n customAttributes: address.customAttributes,\n fax: address.fax,\n firstName: address.firstName,\n lastName: address.lastName,\n middleName: address.middleName,\n postcode: address.postCode,\n prefix: address.prefix,\n region: {\n regionCode: address.region?.code,\n regionId: address.region?.id,\n },\n street: address.street,\n suffix: address.suffix,\n telephone: address.telephone,\n vatId: address.vatId,\n };\n};\n"],"names":["ongoingSetAddressCalls","setAddressOnCart","type","debounceMs","placeOrderBtn","api","setShippingAddress","setBillingAddress","debouncedApi","debounce","address","prev","data","isDataValid","transformAddressFormValuesToAddressInput","estimateShippingCost","prevEstimateShippingData","shouldCancelDebounce","estimateShippingInputCriteria","_a","_b","estimateShippingMethods","_c","_d","validateForm","form","autoScrollOnError","name","ref","formElement","validationResult","scrollToParentContainer","validateForms","forms","createFragment","html","createScopedSelector","fragment","selector","createMetaTag","property","content","meta","newMeta","setMetaTags","dropin","customAttributes","code","value","transformCartAddressToFormValues"],"mappings":"6tBAmCA,IAAIA,EAAyB,EAEtB,SAASC,EAAiB,CAC/B,KAAAC,EAAO,WACP,WAAAC,EAAa,EACb,cAAAC,CACF,EAIG,CACK,MAAAC,EAAMH,IAAS,WAAaI,EAAqBC,EAEjDC,EAAeC,EAClBC,GAAwD,CAC7BV,GAAA,EAC1BK,EAAIK,CAA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Z,EAAQ,SAAR,YAAAY,EAAgB,EAC5B,EACA,OAAQZ,EAAQ,OAChB,OAAQA,EAAQ,OAChB,UAAWA,EAAQ,UACnB,MAAOA,EAAQ,KACjB,CACF"}
|
package/lib/validation.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export declare const validationPatterns: {
|
|
2
2
|
EMAIL: RegExp;
|
|
3
|
+
NOT_EMPTY: RegExp;
|
|
3
4
|
};
|
|
4
5
|
export declare const validateEmail: (email: string) => boolean;
|
|
6
|
+
export declare const validateNotEmpty: (value: string) => boolean;
|
|
7
|
+
export declare const htmlPatterns: {
|
|
8
|
+
EMAIL: string;
|
|
9
|
+
NOT_EMPTY: string;
|
|
10
|
+
};
|
|
5
11
|
//# sourceMappingURL=validation.d.ts.map
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-checkout", "version": "2.2.0-
|
|
1
|
+
{"name": "@dropins/storefront-checkout", "version": "2.2.0-alpha4", "@dropins/tools": "1.6.0-alpha11", "license": "SEE LICENSE IN LICENSE.md"}
|
package/types/index.d.ts
CHANGED
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
export type { InitializeInput, Nullable, SynchronizeInput } from './api';
|
|
18
18
|
export type { TitleProps, UIComponentType } from './components';
|
|
19
19
|
export * from './guards';
|
|
20
|
-
export type { CartModel, FormRef, Item, NegotiableQuoteModel, RenderAPI, } from './storefront';
|
|
20
|
+
export type { CartModel, FormRef, Item, NegotiableQuoteModel, PermissionsModel, RenderAPI, } from './storefront';
|
|
21
21
|
export type { Filter, Selector } from './utils';
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|