@dropins/storefront-checkout 3.0.1 → 3.1.0-beta1

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/chunks/render.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
3
  (function(n,o){try{if(typeof document<"u"){const t=document.createElement("style"),r=o.styleId;for(const e in o.attributes)t.setAttribute(e,o.attributes[e]);t.setAttribute("data-dropin",r),t.appendChild(document.createTextNode(n));const a=document.querySelector('style[data-dropin="sdk"]');if(a)a.after(t);else{const e=document.querySelector('link[rel="stylesheet"], style');e?e.before(t):document.head.append(t)}}}catch(t){console.error("dropin-styles (injectCodeFunction)",t)}})(`.checkout__banner{margin-bottom:var(--spacing-xbig)}
4
- .checkout-shipping-methods__title,.checkout-shipping-methods__title h3{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-shipping-methods__content{position:relative;display:block}.checkout-shipping-methods__method{margin-bottom:var(--spacing-medium);width:fit-content;cursor:pointer;font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-shipping-methods__method:last-child{margin-bottom:0}.dropin-radio-button__label .dropin-price{color:var(--color-neutral-800);font-weight:400}.checkout-shipping-methods__options--busy{opacity:.4;pointer-events:none}.checkout-shipping-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0}.checkout-shipping-methods__options--toggleButton{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium)}.checkout-shipping-methods__options--toggleButton .dropin-toggle-button__content{justify-content:start;display:grid;grid-template-columns:1fr min-content}.checkout-shipping-methods__options--toggleButton .checkout-shipping-methods__method{margin-bottom:0;width:auto}.checkout-shipping-methods__error{margin-top:var(--spacing-medium)}
4
+ .checkout-shipping-methods__title,.checkout-shipping-methods__title h3{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-shipping-methods__content{position:relative;display:block}.checkout-shipping-methods__method{margin-bottom:var(--spacing-medium);width:fit-content;cursor:pointer;font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-shipping-methods__method:last-child{margin-bottom:0}.dropin-radio-button__label .dropin-price{color:var(--color-neutral-800);font-weight:400}.checkout-shipping-methods__price--original{margin-right:var(--spacing-xxsmall)}.checkout-shipping-methods__price-wrapper{display:flex;gap:var(--spacing-xxsmall);align-items:center}.checkout-shipping-methods__options--busy{opacity:.4;pointer-events:none}.checkout-shipping-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0}.checkout-shipping-methods__options--toggleButton{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium)}.checkout-shipping-methods__options--toggleButton .dropin-toggle-button__content{justify-content:start;display:grid;grid-template-columns:1fr min-content}.checkout-shipping-methods__options--toggleButton .checkout-shipping-methods__method{margin-bottom:0;width:auto}.checkout-shipping-methods__error{margin-top:var(--spacing-medium)}
5
5
  .checkout-place-order{display:grid;padding-bottom:var(--spacing-big)}.checkout-place-order__button{align-self:flex-end;justify-self:flex-end}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-place-order{background-color:var(--color-neutral-200);padding:var(--spacing-medium) var(--spacing-medium) var(--spacing-big) var(--spacing-medium)}.checkout-place-order__button{align-self:center;justify-self:stretch}}
6
6
  .checkout-payment-on-account{margin-bottom:var(--spacing-medium)}.checkout-payment-on-account__form{width:100%}.checkout-payment-on-account__credit{display:flex;justify-content:space-between;align-items:center;padding:var(--spacing-small);margin-bottom:var(--spacing-medium);background-color:var(--color-neutral-100);border:1px solid var(--color-neutral-300);border-radius:4px;font-size:14px;line-height:1.4}.checkout-payment-on-account__credit-label{font-weight:500;color:var(--color-neutral-700)}.checkout-payment-on-account__credit-amount{font-weight:600;color:var(--color-success-600)}.checkout-payment-on-account__exceed-message{margin-top:var(--spacing-medium);margin-bottom:var(--spacing-medium)}.checkout-payment-on-account .dropin-field{margin-bottom:0}
7
7
  .checkout-bill-to-shipping-address label{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);gap:0}.checkout-bill-to-shipping-address__error{margin-top:var(--spacing-medium)}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import"./fetch-graphql.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";const s=e=>e?"code"in e&&"value"in e:!1,m=e=>e?e.filter(s).map(r=>{const{code:i,value:o}=r;return{code:i,value:o}}):[],n=e=>{const r=e.street.filter(Boolean);return{city:e.city,company:e.company||void 0,country:f(e.country),customAttributes:m(e.custom_attributes),fax:e.fax||void 0,firstName:e.firstname,id:(e==null?void 0:e.id)||void 0,lastName:e.lastname,middleName:e.middlename||void 0,postCode:e.postcode||void 0,prefix:e.prefix||void 0,region:p(e.region),street:r,suffix:e.suffix||void 0,telephone:e.telephone||void 0,uid:e.uid,vatId:e.vat_id||void 0}},A=e=>{if(e)return n(e)},N=e=>e.filter(r=>!!r).map(r=>{const{available_shipping_methods:i,selected_shipping_method:o,same_as_billing:u,...l}=r;return{...n(l),availableShippingMethods:h(i),selectedShippingMethod:x(o),sameAsBilling:u}}),C=e=>{var r,i;if(e)return{city:e.city,company:e.company,countryCode:e.country.code,customAttributes:e.customAttributes||[],firstName:e.firstName,lastName:e.lastName,postcode:e.postCode,region:(r=e.region)==null?void 0:r.code,regionId:(i=e.region)==null?void 0:i.id,street:e.street,telephone:e.telephone,vatId:e.vatId,prefix:e.prefix,suffix:e.suffix,middleName:e.middleName,fax:e.fax}},f=e=>({code:(e==null?void 0:e.code)??"",label:(e==null?void 0:e.label)??""}),p=e=>{if(!(!(e!=null&&e.code)||!(e!=null&&e.label)))return{code:e.code,name:e.label,id:e.region_id??void 0}},_=(e,r)=>e.amount.value-r.amount.value,v=e=>e==null,t=e=>!(!e||!e.method_code||!e.method_title||v(e.amount.value)||!e.amount.currency),c=e=>({amount:{value:e.amount.value,currency:e.amount.currency},title:e.method_title,code:e.method_code,carrier:{code:e.carrier_code,title:e.carrier_title},value:`${e.carrier_code} - ${e.method_code}`,...e.price_excl_tax&&{amountExclTax:{value:e.price_excl_tax.value,currency:e.price_excl_tax.currency}},...e.price_incl_tax&&{amountInclTax:{value:e.price_incl_tax.value,currency:e.price_incl_tax.currency}}}),x=e=>{if(t(e))return c(e)},h=e=>e?e.filter(t).map(r=>c(r)).sort(_):[];export{h as a,N as b,A as c,x as d,p as e,m as f,f as g,C as t};
3
+ import"./fetch-graphql.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";const s=e=>e?"code"in e&&"value"in e:!1,m=e=>e?e.filter(s).map(r=>{const{code:i,value:o}=r;return{code:i,value:o}}):[],n=e=>{const r=e.street.filter(Boolean);return{city:e.city,company:e.company||void 0,country:f(e.country),customAttributes:m(e.custom_attributes),fax:e.fax||void 0,firstName:e.firstname,id:(e==null?void 0:e.id)||void 0,lastName:e.lastname,middleName:e.middlename||void 0,postCode:e.postcode||void 0,prefix:e.prefix||void 0,region:p(e.region),street:r,suffix:e.suffix||void 0,telephone:e.telephone||void 0,uid:e.uid,vatId:e.vat_id||void 0}},A=e=>{if(e)return n(e)},N=e=>e.filter(r=>!!r).map(r=>{const{available_shipping_methods:i,selected_shipping_method:o,same_as_billing:u,...l}=r;return{...n(l),availableShippingMethods:g(i),selectedShippingMethod:x(o),sameAsBilling:u}}),C=e=>{var r,i;if(e)return{city:e.city,company:e.company,countryCode:e.country.code,customAttributes:e.customAttributes||[],firstName:e.firstName,lastName:e.lastName,postcode:e.postCode,region:(r=e.region)==null?void 0:r.code,regionId:(i=e.region)==null?void 0:i.id,street:e.street,telephone:e.telephone,vatId:e.vatId,prefix:e.prefix,suffix:e.suffix,middleName:e.middleName,fax:e.fax}},f=e=>({code:(e==null?void 0:e.code)??"",label:(e==null?void 0:e.label)??""}),p=e=>{if(!(!(e!=null&&e.code)||!(e!=null&&e.label)))return{code:e.code,name:e.label,id:e.region_id??void 0}},_=(e,r)=>e.amount.value-r.amount.value,v=e=>e==null,t=e=>!(!e||!e.method_code||!e.method_title||v(e.amount.value)||!e.amount.currency),c=e=>({amount:{value:e.amount.value,currency:e.amount.currency},title:e.method_title,code:e.method_code,carrier:{code:e.carrier_code,title:e.carrier_title},value:`${e.carrier_code} - ${e.method_code}`,...e.price_excl_tax&&{amountExclTax:{value:e.price_excl_tax.value,currency:e.price_excl_tax.currency}},...e.price_incl_tax&&{amountInclTax:{value:e.price_incl_tax.value,currency:e.price_incl_tax.currency}},...e.original_amount&&{originalAmount:{value:e.original_amount.value,currency:e.original_amount.currency}}}),x=e=>{if(t(e))return c(e)},g=e=>e?e.filter(t).map(r=>c(r)).sort(_):[];export{g as a,N as b,A as c,x as d,p as e,m as f,f as g,C as t};
4
4
  //# sourceMappingURL=transform-shipping-methods.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform-shipping-methods.js","sources":["/@dropins/storefront-checkout/src/data/transforms/transform-custom-attributes.ts","/@dropins/storefront-checkout/src/data/transforms/transform-cart-address.ts","/@dropins/storefront-checkout/src/data/transforms/transform-country.ts","/@dropins/storefront-checkout/src/data/transforms/transform-region.ts","/@dropins/storefront-checkout/src/data/transforms/transform-shipping-methods.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 { CustomAttribute as CustomAttributeModel } from '@/checkout/data/models/custom-attribute';\nimport { AttributeValue } from '@/checkout/__generated__/types';\n\nconst isAttributeValue = (attribute: any): attribute is AttributeValue => {\n if (!attribute) return false;\n return 'code' in attribute && 'value' in attribute;\n};\n\nexport const transformCustomAttributes = (\n data: Array<AttributeValue | any | null> | null | undefined\n): CustomAttributeModel[] => {\n if (!data) return [];\n return data.filter(isAttributeValue).map((attribute) => {\n const { code, value } = attribute;\n return { code, value };\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 {\n AddressInput as AddressInputModel,\n CartAddress as CartAddressModel,\n CartShippingAddress as CartShippingAddressModel,\n} from '@/checkout/data/models';\n\nimport {\n transformAddressCountry,\n transformAddressRegion,\n transformCustomAttributes,\n transformSelectedShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms';\n\nimport { GetCartQuery } from '@/checkout/__generated__/types';\n\ntype ShippingAddresses = NonNullable<\n GetCartQuery['cart']\n>['shipping_addresses'];\ntype CartShippingAddress = ShippingAddresses[0];\ntype NonNullableShippingAddress = NonNullable<CartShippingAddress>;\n\ntype CartBillingAddress = NonNullable<GetCartQuery['cart']>['billing_address'];\ntype NonNullableBillingAddress = NonNullable<CartBillingAddress>;\n\nconst transformBaseCartAddress = (\n data: NonNullableShippingAddress | NonNullableBillingAddress\n): CartAddressModel => {\n const street = data.street.filter(Boolean) as string[];\n\n return {\n city: data.city,\n company: data.company || undefined,\n country: transformAddressCountry(data.country),\n customAttributes: transformCustomAttributes(data.custom_attributes),\n fax: data.fax || undefined,\n firstName: data.firstname,\n id: data?.id || undefined,\n lastName: data.lastname,\n middleName: data.middlename || undefined,\n postCode: data.postcode || undefined,\n prefix: data.prefix || undefined,\n region: transformAddressRegion(data.region),\n street,\n suffix: data.suffix || undefined,\n telephone: data.telephone || undefined,\n uid: data.uid,\n vatId: data.vat_id || undefined,\n };\n};\n\nconst transformCartBillingAddress = (\n data: CartBillingAddress\n): CartAddressModel | undefined => {\n if (!data) return;\n return transformBaseCartAddress(data);\n};\n\nconst transformCartShippingAddress = (\n data: ShippingAddresses\n): CartShippingAddressModel[] => {\n return data\n .filter((address) => !!address)\n .map((address) => {\n const {\n available_shipping_methods,\n selected_shipping_method,\n same_as_billing,\n ...baseData\n } = address as NonNullableShippingAddress;\n\n return {\n ...transformBaseCartAddress(baseData as NonNullableShippingAddress),\n availableShippingMethods: transformShippingMethods(\n available_shipping_methods\n ),\n selectedShippingMethod: transformSelectedShippingMethod(\n selected_shipping_method\n ),\n sameAsBilling: same_as_billing,\n };\n });\n};\n\nconst transformAddressToCartAddressInput = <T extends CartAddressModel>(\n address?: T | null\n): AddressInputModel | undefined => {\n if (!address) return;\n return {\n city: address.city,\n company: address.company,\n countryCode: address.country.code,\n customAttributes: address.customAttributes || [],\n firstName: address.firstName,\n lastName: address.lastName,\n postcode: address.postCode,\n region: address.region?.code,\n regionId: address.region?.id,\n street: address.street,\n telephone: address.telephone,\n vatId: address.vatId,\n prefix: address.prefix,\n suffix: address.suffix,\n middleName: address.middleName,\n fax: address.fax,\n };\n};\n\nexport {\n CartBillingAddress,\n CartShippingAddress,\n transformAddressToCartAddressInput,\n transformCartBillingAddress,\n transformCartShippingAddress,\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 CartAddressCountry,\n NegotiableQuoteAddressCountry,\n} from '@/checkout/__generated__/types';\n\nimport { Country as CountryModel } from '@/checkout/data/models';\n\ntype AddressCountry = CartAddressCountry | NegotiableQuoteAddressCountry;\ntype OptionalAddressCountry = AddressCountry | undefined | null;\n\nexport const transformAddressCountry = (\n data: OptionalAddressCountry\n): CountryModel => ({\n code: data?.code ?? '',\n label: data?.label ?? '',\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 { Region as RegionModel } from '@/checkout/data/models';\nimport {\n CartAddressRegion,\n NegotiableQuoteAddressRegion,\n} from '@/checkout/__generated__/types';\n\ntype AddressRegion = CartAddressRegion | NegotiableQuoteAddressRegion;\ntype OptionalAddressRegion = AddressRegion | undefined | null;\n\nexport const transformAddressRegion = (\n data: OptionalAddressRegion\n): RegionModel | undefined => {\n if (!data?.code || !data?.label) return;\n return {\n code: data.code,\n name: data.label,\n id: data.region_id ?? undefined,\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 { ShippingMethod } from '@/checkout/data/models/shipping-method';\nimport { GetCartQuery } from '@/checkout/__generated__/types';\n\ntype Cart = NonNullable<GetCartQuery['cart']>;\ntype ShippingAddresses = Cart['shipping_addresses'];\ntype ShippingAddress = NonNullable<NonNullable<ShippingAddresses>[number]>;\ntype AvailableShippingMethods = ShippingAddress['available_shipping_methods'];\ntype AvailableShippingMethod = NonNullable<AvailableShippingMethods>[number];\ntype SelectedShippingMethod = ShippingAddress['selected_shipping_method'];\n\ntype FilteredShippingMethod = Omit<\n NonNullable<AvailableShippingMethod>,\n | 'method_code'\n | 'method_title'\n | 'amount'\n | 'price_excl_tax'\n | 'price_incl_tax'\n> & {\n method_code: string;\n method_title: string;\n amount: {\n value: number;\n currency: string;\n };\n price_excl_tax: {\n value: number;\n currency: string;\n };\n price_incl_tax: {\n value: number;\n currency: string;\n };\n};\n\nconst byPrice = (a: ShippingMethod, b: ShippingMethod) =>\n a.amount.value - b.amount.value;\n\nexport const isNullish = (value: any): boolean =>\n value === null || value === undefined;\n\nconst isValid = (method: AvailableShippingMethod | SelectedShippingMethod) => {\n if (!method) return false;\n if (!method.method_code || !method.method_title) return false;\n if (isNullish(method.amount.value) || !method.amount.currency) return false;\n return true;\n};\n\nconst buildShippingMethod = (data: FilteredShippingMethod): ShippingMethod => {\n return {\n amount: {\n value: data.amount.value,\n currency: data.amount.currency,\n },\n title: data.method_title,\n code: data.method_code,\n carrier: {\n code: data.carrier_code,\n title: data.carrier_title,\n },\n value: `${data.carrier_code} - ${data.method_code}`,\n ...(data.price_excl_tax && {\n amountExclTax: {\n value: data.price_excl_tax.value,\n currency: data.price_excl_tax.currency,\n },\n }),\n ...(data.price_incl_tax && {\n amountInclTax: {\n value: data.price_incl_tax.value,\n currency: data.price_incl_tax.currency,\n },\n }),\n };\n};\n\nexport const transformSelectedShippingMethod = (\n data: SelectedShippingMethod\n): ShippingMethod | undefined => {\n if (!isValid(data)) return;\n return buildShippingMethod(data as FilteredShippingMethod);\n};\n\nexport const transformAvailableShippingMethod = (\n data: AvailableShippingMethod\n): ShippingMethod | undefined => {\n if (!isValid(data)) return;\n return buildShippingMethod(data as FilteredShippingMethod);\n};\n\nexport const transformShippingMethods = (\n data: AvailableShippingMethods\n): ShippingMethod[] => {\n if (!data) return [];\n\n return data\n .filter(isValid)\n .map((method) => buildShippingMethod(method as FilteredShippingMethod))\n .sort(byPrice);\n};\n"],"names":["isAttributeValue","attribute","transformCustomAttributes","data","code","value","transformBaseCartAddress","street","transformAddressCountry","transformAddressRegion","transformCartBillingAddress","transformCartShippingAddress","address","available_shipping_methods","selected_shipping_method","same_as_billing","baseData","transformShippingMethods","transformSelectedShippingMethod","transformAddressToCartAddressInput","_a","_b","byPrice","a","b","isNullish","isValid","method","buildShippingMethod"],"mappings":"6FAoBA,MAAMA,EAAoBC,GACnBA,EACE,SAAUA,GAAa,UAAWA,EADlB,GAIZC,EACXC,GAEKA,EACEA,EAAK,OAAOH,CAAgB,EAAE,IAAKC,GAAc,CAChD,KAAA,CAAE,KAAAG,EAAM,MAAAC,CAAA,EAAUJ,EACjB,MAAA,CAAE,KAAAG,EAAM,MAAAC,CAAM,CAAA,CACtB,EAJiB,CAAC,ECcfC,EACJH,GACqB,CACrB,MAAMI,EAASJ,EAAK,OAAO,OAAO,OAAO,EAElC,MAAA,CACL,KAAMA,EAAK,KACX,QAASA,EAAK,SAAW,OACzB,QAASK,EAAwBL,EAAK,OAAO,EAC7C,iBAAkBD,EAA0BC,EAAK,iBAAiB,EAClE,IAAKA,EAAK,KAAO,OACjB,UAAWA,EAAK,UAChB,IAAIA,GAAA,YAAAA,EAAM,KAAM,OAChB,SAAUA,EAAK,SACf,WAAYA,EAAK,YAAc,OAC/B,SAAUA,EAAK,UAAY,OAC3B,OAAQA,EAAK,QAAU,OACvB,OAAQM,EAAuBN,EAAK,MAAM,EAC1C,OAAAI,EACA,OAAQJ,EAAK,QAAU,OACvB,UAAWA,EAAK,WAAa,OAC7B,IAAKA,EAAK,IACV,MAAOA,EAAK,QAAU,MACxB,CACF,EAEMO,EACJP,GACiC,CACjC,GAAKA,EACL,OAAOG,EAAy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,CAACA,EAAO,OAAO,UAIjDC,EAAuBzB,IACpB,CACL,OAAQ,CACN,MAAOA,EAAK,OAAO,MACnB,SAAUA,EAAK,OAAO,QACxB,EACA,MAAOA,EAAK,aACZ,KAAMA,EAAK,YACX,QAAS,CACP,KAAMA,EAAK,aACX,MAAOA,EAAK,aACd,EACA,MAAO,GAAGA,EAAK,YAAY,MAAMA,EAAK,WAAW,GACjD,GAAIA,EAAK,gBAAkB,CACzB,cAAe,CACb,MAAOA,EAAK,eAAe,MAC3B,SAAUA,EAAK,eAAe,QAAA,CAElC,EACA,GAAIA,EAAK,gBAAkB,CACzB,cAAe,CACb,MAAOA,EAAK,eAAe,MAC3B,SAAUA,EAAK,eAAe,QAAA,CAChC,CAEJ,GAGWe,EACXf,GAC+B,CAC3B,GAACuB,EAAQvB,CAAI,EACjB,OAAOyB,EAAoBzB,CAA8B,CAC3D,EASac,EACXd,GAEKA,EAEEA,EACJ,OAAOuB,CAAO,EACd,IAAKC,GAAWC,EAAoBD,CAAgC,CAAC,EACrE,KAAKL,CAAO,EALG,CAAC"}
1
+ {"version":3,"file":"transform-shipping-methods.js","sources":["/@dropins/storefront-checkout/src/data/transforms/transform-custom-attributes.ts","/@dropins/storefront-checkout/src/data/transforms/transform-cart-address.ts","/@dropins/storefront-checkout/src/data/transforms/transform-country.ts","/@dropins/storefront-checkout/src/data/transforms/transform-region.ts","/@dropins/storefront-checkout/src/data/transforms/transform-shipping-methods.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 { CustomAttribute as CustomAttributeModel } from '@/checkout/data/models/custom-attribute';\nimport { AttributeValue } from '@/checkout/__generated__/types';\n\nconst isAttributeValue = (attribute: any): attribute is AttributeValue => {\n if (!attribute) return false;\n return 'code' in attribute && 'value' in attribute;\n};\n\nexport const transformCustomAttributes = (\n data: Array<AttributeValue | any | null> | null | undefined\n): CustomAttributeModel[] => {\n if (!data) return [];\n return data.filter(isAttributeValue).map((attribute) => {\n const { code, value } = attribute;\n return { code, value };\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 {\n AddressInput as AddressInputModel,\n CartAddress as CartAddressModel,\n CartShippingAddress as CartShippingAddressModel,\n} from '@/checkout/data/models';\n\nimport {\n transformAddressCountry,\n transformAddressRegion,\n transformCustomAttributes,\n transformSelectedShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms';\n\nimport { GetCartQuery } from '@/checkout/__generated__/types';\n\ntype ShippingAddresses = NonNullable<\n GetCartQuery['cart']\n>['shipping_addresses'];\ntype CartShippingAddress = ShippingAddresses[0];\ntype NonNullableShippingAddress = NonNullable<CartShippingAddress>;\n\ntype CartBillingAddress = NonNullable<GetCartQuery['cart']>['billing_address'];\ntype NonNullableBillingAddress = NonNullable<CartBillingAddress>;\n\nconst transformBaseCartAddress = (\n data: NonNullableShippingAddress | NonNullableBillingAddress\n): CartAddressModel => {\n const street = data.street.filter(Boolean) as string[];\n\n return {\n city: data.city,\n company: data.company || undefined,\n country: transformAddressCountry(data.country),\n customAttributes: transformCustomAttributes(data.custom_attributes),\n fax: data.fax || undefined,\n firstName: data.firstname,\n id: data?.id || undefined,\n lastName: data.lastname,\n middleName: data.middlename || undefined,\n postCode: data.postcode || undefined,\n prefix: data.prefix || undefined,\n region: transformAddressRegion(data.region),\n street,\n suffix: data.suffix || undefined,\n telephone: data.telephone || undefined,\n uid: data.uid,\n vatId: data.vat_id || undefined,\n };\n};\n\nconst transformCartBillingAddress = (\n data: CartBillingAddress\n): CartAddressModel | undefined => {\n if (!data) return;\n return transformBaseCartAddress(data);\n};\n\nconst transformCartShippingAddress = (\n data: ShippingAddresses\n): CartShippingAddressModel[] => {\n return data\n .filter((address) => !!address)\n .map((address) => {\n const {\n available_shipping_methods,\n selected_shipping_method,\n same_as_billing,\n ...baseData\n } = address as NonNullableShippingAddress;\n\n return {\n ...transformBaseCartAddress(baseData as NonNullableShippingAddress),\n availableShippingMethods: transformShippingMethods(\n available_shipping_methods\n ),\n selectedShippingMethod: transformSelectedShippingMethod(\n selected_shipping_method\n ),\n sameAsBilling: same_as_billing,\n };\n });\n};\n\nconst transformAddressToCartAddressInput = <T extends CartAddressModel>(\n address?: T | null\n): AddressInputModel | undefined => {\n if (!address) return;\n return {\n city: address.city,\n company: address.company,\n countryCode: address.country.code,\n customAttributes: address.customAttributes || [],\n firstName: address.firstName,\n lastName: address.lastName,\n postcode: address.postCode,\n region: address.region?.code,\n regionId: address.region?.id,\n street: address.street,\n telephone: address.telephone,\n vatId: address.vatId,\n prefix: address.prefix,\n suffix: address.suffix,\n middleName: address.middleName,\n fax: address.fax,\n };\n};\n\nexport {\n CartBillingAddress,\n CartShippingAddress,\n transformAddressToCartAddressInput,\n transformCartBillingAddress,\n transformCartShippingAddress,\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 CartAddressCountry,\n NegotiableQuoteAddressCountry,\n} from '@/checkout/__generated__/types';\n\nimport { Country as CountryModel } from '@/checkout/data/models';\n\ntype AddressCountry = CartAddressCountry | NegotiableQuoteAddressCountry;\ntype OptionalAddressCountry = AddressCountry | undefined | null;\n\nexport const transformAddressCountry = (\n data: OptionalAddressCountry\n): CountryModel => ({\n code: data?.code ?? '',\n label: data?.label ?? '',\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 { Region as RegionModel } from '@/checkout/data/models';\nimport {\n CartAddressRegion,\n NegotiableQuoteAddressRegion,\n} from '@/checkout/__generated__/types';\n\ntype AddressRegion = CartAddressRegion | NegotiableQuoteAddressRegion;\ntype OptionalAddressRegion = AddressRegion | undefined | null;\n\nexport const transformAddressRegion = (\n data: OptionalAddressRegion\n): RegionModel | undefined => {\n if (!data?.code || !data?.label) return;\n return {\n code: data.code,\n name: data.label,\n id: data.region_id ?? undefined,\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 { ShippingMethod } from '@/checkout/data/models/shipping-method';\nimport { GetCartQuery } from '@/checkout/__generated__/types';\n\ntype Cart = NonNullable<GetCartQuery['cart']>;\ntype ShippingAddresses = Cart['shipping_addresses'];\ntype ShippingAddress = NonNullable<NonNullable<ShippingAddresses>[number]>;\ntype AvailableShippingMethods = ShippingAddress['available_shipping_methods'];\ntype AvailableShippingMethod = NonNullable<AvailableShippingMethods>[number];\ntype SelectedShippingMethod = ShippingAddress['selected_shipping_method'];\n\ntype FilteredShippingMethod = Omit<\n NonNullable<AvailableShippingMethod>,\n | 'method_code'\n | 'method_title'\n | 'amount'\n | 'price_excl_tax'\n | 'price_incl_tax'\n> & {\n method_code: string;\n method_title: string;\n amount: {\n value: number;\n currency: string;\n };\n price_excl_tax: {\n value: number;\n currency: string;\n };\n price_incl_tax: {\n value: number;\n currency: string;\n };\n};\n\nconst byPrice = (a: ShippingMethod, b: ShippingMethod) =>\n a.amount.value - b.amount.value;\n\nexport const isNullish = (value: any): boolean =>\n value === null || value === undefined;\n\nconst isValid = (method: AvailableShippingMethod | SelectedShippingMethod) => {\n if (!method) return false;\n if (!method.method_code || !method.method_title) return false;\n if (isNullish(method.amount.value) || !method.amount.currency) return false;\n return true;\n};\n\nconst buildShippingMethod = (data: FilteredShippingMethod): ShippingMethod => {\n return {\n amount: {\n value: data.amount.value,\n currency: data.amount.currency,\n },\n title: data.method_title,\n code: data.method_code,\n carrier: {\n code: data.carrier_code,\n title: data.carrier_title,\n },\n value: `${data.carrier_code} - ${data.method_code}`,\n ...(data.price_excl_tax && {\n amountExclTax: {\n value: data.price_excl_tax.value,\n currency: data.price_excl_tax.currency,\n },\n }),\n ...(data.price_incl_tax && {\n amountInclTax: {\n value: data.price_incl_tax.value,\n currency: data.price_incl_tax.currency,\n },\n }),\n ...((data as any).original_amount && {\n originalAmount: {\n value: (data as any).original_amount.value,\n currency: (data as any).original_amount.currency,\n },\n }),\n };\n};\n\nexport const transformSelectedShippingMethod = (\n data: SelectedShippingMethod\n): ShippingMethod | undefined => {\n if (!isValid(data)) return;\n return buildShippingMethod(data as FilteredShippingMethod);\n};\n\nexport const transformAvailableShippingMethod = (\n data: AvailableShippingMethod\n): ShippingMethod | undefined => {\n if (!isValid(data)) return;\n return buildShippingMethod(data as FilteredShippingMethod);\n};\n\nexport const transformShippingMethods = (\n data: AvailableShippingMethods\n): ShippingMethod[] => {\n if (!data) return [];\n\n return data\n .filter(isValid)\n .map((method) => buildShippingMethod(method as FilteredShippingMethod))\n .sort(byPrice);\n};\n"],"names":["isAttributeValue","attribute","transformCustomAttributes","data","code","value","transformBaseCartAddress","street","transformAddressCountry","transformAddressRegion","transformCartBillingAddress","transformCartShippingAddress","address","available_shipping_methods","selected_shipping_method","same_as_billing","baseData","transformShippingMethods","transformSelectedShippingMethod","transformAddressToCartAddressInput","_a","_b","byPrice","a","b","isNullish","isValid","method","buildShippingMethod"],"mappings":"6FAoBA,MAAMA,EAAoBC,GACnBA,EACE,SAAUA,GAAa,UAAWA,EADlB,GAIZC,EACXC,GAEKA,EACEA,EAAK,OAAOH,CAAgB,EAAE,IAAKC,GAAc,CAChD,KAAA,CAAE,KAAAG,EAAM,MAAAC,CAAA,EAAUJ,EACjB,MAAA,CAAE,KAAAG,EAAM,MAAAC,CAAM,CAAA,CACtB,EAJiB,CAAC,ECcfC,EACJH,GACqB,CACrB,MAAMI,EAASJ,EAAK,OAAO,OAAO,OAAO,EAElC,MAAA,CACL,KAAMA,EAAK,KACX,QAASA,EAAK,SAAW,OACzB,QAASK,EAAwBL,EAAK,OAAO,EAC7C,iBAAkBD,EAA0BC,EAAK,iBAAiB,EAClE,IAAKA,EAAK,KAAO,OACjB,UAAWA,EAAK,UAChB,IAAIA,GAAA,YAAAA,EAAM,KAAM,OAChB,SAAUA,EAAK,SACf,WAAYA,EAAK,YAAc,OAC/B,SAAUA,EAAK,UAAY,OAC3B,OAAQA,EAAK,QAAU,OACvB,OAAQM,EAAuBN,EAAK,MAAM,EAC1C,OAAAI,EACA,OAAQJ,EAAK,QAAU,OACvB,UAAWA,EAAK,WAAa,OAC7B,IAAKA,E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AWC,GACX,GAACA,GACD,CAACA,EAAO,aAAe,CAACA,EAAO,cAC/BF,EAAUE,EAAO,OAAO,KAAK,GAAK,CAACA,EAAO,OAAO,UAIjDC,EAAuBzB,IACpB,CACL,OAAQ,CACN,MAAOA,EAAK,OAAO,MACnB,SAAUA,EAAK,OAAO,QACxB,EACA,MAAOA,EAAK,aACZ,KAAMA,EAAK,YACX,QAAS,CACP,KAAMA,EAAK,aACX,MAAOA,EAAK,aACd,EACA,MAAO,GAAGA,EAAK,YAAY,MAAMA,EAAK,WAAW,GACjD,GAAIA,EAAK,gBAAkB,CACzB,cAAe,CACb,MAAOA,EAAK,eAAe,MAC3B,SAAUA,EAAK,eAAe,QAAA,CAElC,EACA,GAAIA,EAAK,gBAAkB,CACzB,cAAe,CACb,MAAOA,EAAK,eAAe,MAC3B,SAAUA,EAAK,eAAe,QAAA,CAElC,EACA,GAAKA,EAAa,iBAAmB,CACnC,eAAgB,CACd,MAAQA,EAAa,gBAAgB,MACrC,SAAWA,EAAa,gBAAgB,QAAA,CAC1C,CAEJ,GAGWe,EACXf,GAC+B,CAC3B,GAACuB,EAAQvB,CAAI,EACjB,OAAOyB,EAAoBzB,CAA8B,CAC3D,EASac,EACXd,GAEKA,EAEEA,EACJ,OAAOuB,CAAO,EACd,IAAKC,GAAWC,EAAoBD,CAAgC,CAAC,EACrE,KAAKL,CAAO,EALG,CAAC"}
@@ -11,6 +11,7 @@ export interface LoginFormProps extends Omit<HTMLAttributes<HTMLFormElement>, 't
11
11
  onEmailBlur: (event: Event) => void;
12
12
  onEmailChange: (event: Event) => void;
13
13
  onEmailInvalid: (event: Event) => void;
14
+ preferences?: VNode;
14
15
  title?: VNode;
15
16
  }
16
17
  export declare const LoginForm: FunctionComponent<LoginFormProps & import('..').ConditionalProps>;
@@ -23,6 +23,11 @@ export interface LoginFormProps extends HTMLAttributes<HTMLFormElement>, TitlePr
23
23
  Heading?: SlotProps<{
24
24
  authenticated: boolean;
25
25
  }>;
26
+ Preferences?: SlotProps<{
27
+ email: string;
28
+ isEmailValid: boolean;
29
+ isAuthenticated: boolean;
30
+ }>;
26
31
  } & TitleProps['slots'];
27
32
  }
28
33
  export declare const LoginForm: Container<LoginFormProps>;
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as r,jsxs as u,Fragment as le}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/fetch-graphql.js";import{VComponent as G,classes as se,Slot as J}from"@dropins/tools/lib.js";import{b as ce,a as me}from"../chunks/events2.js";import{a as z}from"../chunks/validation.js";import{n as B,g as K}from"../chunks/values.js";import{events as D}from"@dropins/tools/event-bus.js";import{i as ue,s as he,g as de}from"../chunks/setGuestEmailOnCart.js";import{Field as ge,Input as fe,Skeleton as pe,SkeletonRow as Q}from"@dropins/tools/components.js";import{useText as I}from"@dropins/tools/i18n.js";import"../chunks/TermsAndConditions.js";/* empty css */import{W as ke}from"../chunks/ConditionalWrapper.js";import"@dropins/tools/preact-compat.js";/* empty css *//* empty css *//* empty css */import{useState as k,useRef as Le,useCallback as d,useEffect as w,useMemo as M}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";import"../chunks/transform-shipping-methods.js";import"../chunks/classifiers.js";const ve=({value:o,error:n,hint:a,onChange:g,onBlur:L,onInvalid:c})=>{const l=I({LoginFormLabel:"Checkout.LoginForm.ariaLabel",LoginFormFloatingLabel:"Checkout.LoginForm.floatingLabel",LoginFormPlaceholder:"Checkout.LoginForm.placeholder"});return r(ge,{error:n,hint:a,children:r(fe,{"aria-label":l.LoginFormLabel,"aria-required":!0,autocomplete:"email",floatingLabel:l.LoginFormFloatingLabel,id:"customer-email",name:"customer-email",placeholder:l.LoginFormPlaceholder,required:!0,type:"email",value:o,onBlur:L,onChange:g,onInvalid:c})})},Fe=({onClick:o})=>{const n=I({account:"Checkout.LoginForm.account",signIn:"Checkout.LoginForm.signIn"});return u("div",{className:"checkout-login-form__sign-in",children:[n.account,r("a",{className:"checkout-login-form__link","data-testid":"sign-in-link",href:"#",rel:"noreferrer",target:"_blank",onClick:a=>{a.preventDefault(),o(a)},children:n.signIn})]})},_e=()=>u(pe,{"data-testid":"login-form-skeleton",children:[r(Q,{fullWidth:!0,variant:"heading"}),r(Q,{fullWidth:!0,size:"medium"})]}),be=({className:o,customer:n,email:a,error:g,headingContent:L,hint:c,name:l,onEmailBlur:f,onEmailChange:m,onEmailInvalid:s,title:F,...y})=>u("div",{className:"checkout-login-form","data-testid":"checkout-login-form",children:[u("div",{className:"checkout-login-form__heading",children:[F&&r(G,{className:"checkout-login-form__title",node:F}),L&&r(G,{className:"checkout-login-form__heading-label",node:L})]}),n?u("div",{className:"checkout-login-form__customer-details",children:[r("div",{className:"checkout-login-form__customer-name",children:`${n.firstName} ${n.lastName}`}),r("div",{className:"checkout-login-form__customer-email",children:n.email})]}):r("div",{className:"checkout-login-form__content",children:u("form",{...y,noValidate:!0,className:se(["dropin-login-form__form",o]),name:l,children:[r("button",{disabled:!0,"aria-hidden":"true",style:"display: none",type:"submit"}),r(ve,{error:g,hint:c,value:a,onBlur:f,onChange:m,onInvalid:s})]})})]}),Ee=ke(be,_e),Ce=({onClick:o})=>{const n=I({switch:"Checkout.LoginForm.switch",signOut:"Checkout.LoginForm.signOut"});return u("p",{className:"checkout-login-form__sign-out",children:[n.switch,r("a",{className:"checkout-login-form__link",href:"#",rel:"noreferrer",target:"_blank",onClick:a=>{a.preventDefault(),o==null||o(a)},children:n.signOut})]})},Ne=1e3,Xe=({active:o=!0,autoSync:n=!0,displayHeadingContent:a=!0,displayTitle:g=!0,initialData:L,onCartSyncError:c,onSignInClick:l,onSignOutClick:f,onValidationError:m,slots:s,...F})=>{const[y,X]=k(null),[Y,A]=k(""),[Z,p]=k(""),[x,S]=k(!1),[V,_]=k(!0),[ee,W]=k(!1),h=Le(null),{alreadyHaveAccountHint:$,cartSyncError:j,defaultTitle:q,fasterCheckoutHint:O,invalidEmailError:b,missingEmailError:E,signInLabel:P}=I({alreadyHaveAccountHint:"Checkout.LoginForm.emailExists.alreadyHaveAccount",cartSyncError:"Checkout.LoginForm.cartSyncError",defaultTitle:"Checkout.LoginForm.title",fasterCheckoutHint:"Checkout.LoginForm.emailExists.forFasterCheckout",invalidEmailError:"Checkout.LoginForm.invalidEmailError",missingEmailError:"Checkout.LoginForm.missingEmailError",signInLabel:"Checkout.LoginForm.emailExists.signInButton"}),C=d(e=>{!z(e)||e===ce()||(ue(e).then(t=>{_(t)}).catch(t=>{console.error(t),_(!0)}),n&&he(e).catch(t=>{c==null||c({email:e,error:t}),c||p(j)}))},[n,c,j]),te=d(e=>{const i=e.target.value;A(i),_(!0),p(""),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{C(i),B({email:i}),h.current=null},Ne)},[C]),ie=d(e=>{const t=e.target,i=t.value.trim();if(z(i)){if(p(""),t.setCustomValidity(""),!h.current)return;clearTimeout(h.current),h.current=null,C(i),B({email:i});return}const U=i===""?"missing":"invalid",H=U==="missing"?E:b;if(m){m({email:i,message:H,type:U});return}p(H),t.setCustomValidity(H)},[b,E,m,C]),re=d(e=>{const t=e.target,i=t.validity,T=i.valueMissing?E:b;if(!m){p(T);return}m({email:t.value,message:T,type:i.valueMissing?"missing":"invalid"})},[E,b,m]),N=d(()=>{const e=K("email")??"",t=z(e);l==null||l(t?e:"")},[l]),R=d(()=>{f==null||f()},[f]),v=d(e=>{const t=K("email")??"",i=(e==null?void 0:e.email)??"";i!==t&&(A(i),p(""),_(!0),B({email:i}))},[]);w(()=>{if(!o)return;const e=D.on("authenticated",t=>{S(t),de().then(i=>{X(i)}).catch(console.error)},{eager:!0});return()=>{e==null||e.off()}},[o]),w(()=>{if(!o)return;const e=me();if(e){W(!0);const i=e.email??"";i&&A(i),v(e);return}const t=D.on("checkout/initialized",i=>{W(!0),v(i)},{eager:!0});return()=>{t==null||t.off()}},[o,v]),w(()=>{if(!o)return;const e=D.on("checkout/updated",v,{eager:!1});return()=>{e==null||e.off()}},[o,v]);const oe=M(()=>{if(g)return r(J,{name:"checkout-login-form-title",slot:s==null?void 0:s.Title,children:r("h2",{children:q})})},[g,s,q]),ne=M(()=>{if(a)return r(J,{context:{authenticated:x},name:"checkout-login-form-heading-label",slot:s==null?void 0:s.Heading,children:x?r(Ce,{onClick:R}):r(Fe,{onClick:N})})},[a,x,s,N,R]),ae=M(()=>V?"":u(le,{children:[$," ",r("a",{href:"#",onClick:N,children:P})," ",O]}),[V,$,P,O,N]);return r(Ee,{...F,customer:y,email:Y,error:Z,headingContent:ne,hint:ae,initialized:ee,title:oe,visible:o,onEmailBlur:ie,onEmailChange:te,onEmailInvalid:re})};export{Xe as LoginForm,Xe as default};
3
+ import{jsx as r,jsxs as u,Fragment as ce}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/fetch-graphql.js";import{VComponent as w,classes as se,Slot as M}from"@dropins/tools/lib.js";import{b as me,a as ue}from"../chunks/events2.js";import{a as A}from"../chunks/validation.js";import{n as W,g as X}from"../chunks/values.js";import{events as P}from"@dropins/tools/event-bus.js";import{i as he,s as de,g as ge}from"../chunks/setGuestEmailOnCart.js";import{Field as fe,Input as pe,Skeleton as ke,SkeletonRow as Y}from"@dropins/tools/components.js";import{useText as H}from"@dropins/tools/i18n.js";import"../chunks/TermsAndConditions.js";/* empty css */import{W as Le}from"../chunks/ConditionalWrapper.js";import"@dropins/tools/preact-compat.js";/* empty css *//* empty css *//* empty css */import{useState as k,useRef as ve,useCallback as d,useEffect as $,useMemo as T}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";import"../chunks/transform-shipping-methods.js";import"../chunks/classifiers.js";const Fe=({value:n,error:o,hint:l,onChange:g,onBlur:L,onInvalid:s})=>{const c=H({LoginFormLabel:"Checkout.LoginForm.ariaLabel",LoginFormFloatingLabel:"Checkout.LoginForm.floatingLabel",LoginFormPlaceholder:"Checkout.LoginForm.placeholder"});return r(fe,{error:o,hint:l,children:r(pe,{"aria-label":c.LoginFormLabel,"aria-required":!0,autocomplete:"email",floatingLabel:c.LoginFormFloatingLabel,id:"customer-email",name:"customer-email",placeholder:c.LoginFormPlaceholder,required:!0,type:"email",value:n,onBlur:L,onChange:g,onInvalid:s})})},_e=({onClick:n})=>{const o=H({account:"Checkout.LoginForm.account",signIn:"Checkout.LoginForm.signIn"});return u("div",{className:"checkout-login-form__sign-in",children:[o.account,r("a",{className:"checkout-login-form__link","data-testid":"sign-in-link",href:"#",rel:"noreferrer",target:"_blank",onClick:l=>{l.preventDefault(),n(l)},children:o.signIn})]})},be=()=>u(ke,{"data-testid":"login-form-skeleton",children:[r(Y,{fullWidth:!0,variant:"heading"}),r(Y,{fullWidth:!0,size:"medium"})]}),Ee=({className:n,customer:o,email:l,error:g,headingContent:L,hint:s,name:c,onEmailBlur:f,onEmailChange:m,onEmailInvalid:a,preferences:_,title:b,...z})=>u("div",{className:"checkout-login-form","data-testid":"checkout-login-form",children:[u("div",{className:"checkout-login-form__heading",children:[b&&r(w,{className:"checkout-login-form__title",node:b}),L&&r(w,{className:"checkout-login-form__heading-label",node:L})]}),o?u("div",{className:"checkout-login-form__customer-details",children:[r("div",{className:"checkout-login-form__customer-name",children:`${o.firstName} ${o.lastName}`}),r("div",{className:"checkout-login-form__customer-email",children:o.email})]}):r("div",{className:"checkout-login-form__content",children:u("form",{...z,noValidate:!0,className:se(["dropin-login-form__form",n]),name:c,children:[r("button",{disabled:!0,"aria-hidden":"true",style:"display: none",type:"submit"}),r(Fe,{error:g,hint:s,value:l,onBlur:f,onChange:m,onInvalid:a}),_&&r(w,{className:"checkout-login-form__preferences",node:_})]})})]}),Ce=Le(Ee,be),Ne=({onClick:n})=>{const o=H({switch:"Checkout.LoginForm.switch",signOut:"Checkout.LoginForm.signOut"});return u("p",{className:"checkout-login-form__sign-out",children:[o.switch,r("a",{className:"checkout-login-form__link",href:"#",rel:"noreferrer",target:"_blank",onClick:l=>{l.preventDefault(),n==null||n(l)},children:o.signOut})]})},Ie=1e3,Ye=({active:n=!0,autoSync:o=!0,displayHeadingContent:l=!0,displayTitle:g=!0,initialData:L,onCartSyncError:s,onSignInClick:c,onSignOutClick:f,onValidationError:m,slots:a,..._})=>{const[b,z]=k(null),[E,B]=k(""),[Z,p]=k(""),[v,S]=k(!1),[j,C]=k(!0),[ee,q]=k(!1),h=ve(null),{alreadyHaveAccountHint:O,cartSyncError:R,defaultTitle:U,fasterCheckoutHint:G,invalidEmailError:N,missingEmailError:I,signInLabel:J}=H({alreadyHaveAccountHint:"Checkout.LoginForm.emailExists.alreadyHaveAccount",cartSyncError:"Checkout.LoginForm.cartSyncError",defaultTitle:"Checkout.LoginForm.title",fasterCheckoutHint:"Checkout.LoginForm.emailExists.forFasterCheckout",invalidEmailError:"Checkout.LoginForm.invalidEmailError",missingEmailError:"Checkout.LoginForm.missingEmailError",signInLabel:"Checkout.LoginForm.emailExists.signInButton"}),x=d(e=>{!A(e)||e===me()||(he(e).then(t=>{C(t)}).catch(t=>{console.error(t),C(!0)}),o&&de(e).catch(t=>{s==null||s({email:e,error:t}),s||p(R)}))},[o,s,R]),te=d(e=>{const i=e.target.value;B(i),C(!0),p(""),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{x(i),W({email:i}),h.current=null},Ie)},[x]),ie=d(e=>{const t=e.target,i=t.value.trim();if(A(i)){if(p(""),t.setCustomValidity(""),!h.current)return;clearTimeout(h.current),h.current=null,x(i),W({email:i});return}const Q=i===""?"missing":"invalid",V=Q==="missing"?I:N;if(m){m({email:i,message:V,type:Q});return}p(V),t.setCustomValidity(V)},[N,I,m,x]),re=d(e=>{const t=e.target,i=t.validity,D=i.valueMissing?I:N;if(!m){p(D);return}m({email:t.value,message:D,type:i.valueMissing?"missing":"invalid"})},[I,N,m]),y=d(()=>{const e=X("email")??"",t=A(e);c==null||c(t?e:"")},[c]),K=d(()=>{f==null||f()},[f]),F=d(e=>{const t=X("email")??"",i=(e==null?void 0:e.email)??"";i!==t&&(B(i),p(""),C(!0),W({email:i}))},[]);$(()=>{if(!n)return;const e=P.on("authenticated",t=>{S(t),ge().then(i=>{z(i)}).catch(console.error)},{eager:!0});return()=>{e==null||e.off()}},[n]),$(()=>{if(!n)return;const e=ue();if(e){q(!0);const i=e.email??"";i&&B(i),F(e);return}const t=P.on("checkout/initialized",i=>{q(!0),F(i)},{eager:!0});return()=>{t==null||t.off()}},[n,F]),$(()=>{if(!n)return;const e=P.on("checkout/updated",F,{eager:!1});return()=>{e==null||e.off()}},[n,F]);const ne=T(()=>{if(g)return r(M,{name:"checkout-login-form-title",slot:a==null?void 0:a.Title,children:r("h2",{children:U})})},[g,a,U]),oe=T(()=>{if(l)return r(M,{context:{authenticated:v},name:"checkout-login-form-heading-label",slot:a==null?void 0:a.Heading,children:v?r(Ne,{onClick:K}):r(_e,{onClick:y})})},[l,v,a,y,K]),ae=T(()=>j?"":u(ce,{children:[O," ",r("a",{href:"#",onClick:y,children:J})," ",G]}),[j,O,J,G,y]),le=T(()=>r(M,{context:{email:E,isEmailValid:A(E),isAuthenticated:v},name:"checkout-login-form-preferences",slot:a==null?void 0:a.Preferences}),[E,v,a]);return r(Ce,{..._,customer:b,email:E,error:Z,headingContent:oe,hint:ae,initialized:ee,preferences:le,title:ne,visible:n,onEmailBlur:ie,onEmailChange:te,onEmailInvalid:re})};export{Ye as LoginForm,Ye as default};
4
4
  //# sourceMappingURL=LoginForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoginForm.js","sources":["/@dropins/storefront-checkout/src/components/LoginForm/Email.tsx","/@dropins/storefront-checkout/src/components/LoginForm/SignIn.tsx","/@dropins/storefront-checkout/src/components/LoginForm/LoginFormSkeleton.tsx","/@dropins/storefront-checkout/src/components/LoginForm/LoginForm.tsx","/@dropins/storefront-checkout/src/components/LoginForm/SignOut.tsx","/@dropins/storefront-checkout/src/containers/LoginForm/LoginForm.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 { Field, Input } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface LoginEmailProps extends HTMLAttributes<HTMLInputElement> {\n value: string;\n error: string;\n hint: string;\n onChange: (event: Event) => void;\n onBlur: (event: Event) => void;\n onInvalid: (event: Event) => void;\n}\n\nexport const Email: FunctionComponent<LoginEmailProps> = ({\n value,\n error,\n hint,\n onChange,\n onBlur,\n onInvalid,\n}) => {\n const translations = useText({\n LoginFormLabel: 'Checkout.LoginForm.ariaLabel',\n LoginFormFloatingLabel: 'Checkout.LoginForm.floatingLabel',\n LoginFormPlaceholder: 'Checkout.LoginForm.placeholder',\n });\n\n return (\n <Field error={error} hint={hint}>\n <Input\n aria-label={translations.LoginFormLabel}\n aria-required={true}\n autocomplete=\"email\"\n floatingLabel={translations.LoginFormFloatingLabel}\n id=\"customer-email\"\n name=\"customer-email\"\n placeholder={translations.LoginFormPlaceholder}\n required={true}\n type=\"email\"\n value={value}\n onBlur={onBlur}\n onChange={onChange}\n onInvalid={onInvalid}\n />\n </Field>\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 { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\n\ninterface SignInProps {\n onClick: (event: Event) => void;\n}\n\nexport const SignIn: FunctionComponent<SignInProps> = ({ onClick }) => {\n const translations = useText({\n account: 'Checkout.LoginForm.account',\n signIn: 'Checkout.LoginForm.signIn'\n });\n\n return (\n <div className=\"checkout-login-form__sign-in\">\n {translations.account}\n\n <a\n className=\"checkout-login-form__link\"\n data-testid=\"sign-in-link\"\n href=\"#\"\n rel=\"noreferrer\"\n target=\"_blank\"\n onClick={(event) => {\n event.preventDefault();\n onClick(event);\n }}\n >\n {translations.signIn}\n </a>\n </div>\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 { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const LoginFormSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"login-form-skeleton\">\n <SkeletonRow fullWidth={true} variant=\"heading\" />\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 { Email } from '@/checkout/components';\nimport { WithConditionals } from '@/checkout/components/ConditionalWrapper/ConditionalWrapper';\nimport '@/checkout/components/LoginForm/LoginForm.css';\nimport { LoginFormSkeleton } from '@/checkout/components/LoginForm/LoginFormSkeleton';\nimport { Customer } from '@/checkout/data/models';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface LoginFormProps\n extends Omit<HTMLAttributes<HTMLFormElement>, 'title'> {\n customer: Customer | null;\n email: string;\n error: string;\n headingContent?: VNode;\n hint: string | VNode;\n onEmailBlur: (event: Event) => void;\n onEmailChange: (event: Event) => void;\n onEmailInvalid: (event: Event) => void;\n title?: VNode;\n}\n\nconst LoginFormComponent: FunctionComponent<LoginFormProps> = ({\n className,\n customer,\n email,\n error,\n headingContent,\n hint,\n name,\n onEmailBlur,\n onEmailChange,\n onEmailInvalid,\n title,\n ...props\n}) => {\n return (\n <div className=\"checkout-login-form\" data-testid=\"checkout-login-form\">\n <div className=\"checkout-login-form__heading\">\n {title && (\n <VComponent className=\"checkout-login-form__title\" node={title} />\n )}\n\n {headingContent && (\n <VComponent\n className=\"checkout-login-form__heading-label\"\n node={headingContent}\n />\n )}\n </div>\n\n {customer ? (\n <div className=\"checkout-login-form__customer-details\">\n <div className=\"checkout-login-form__customer-name\">\n {`${customer.firstName} ${customer.lastName}`}\n </div>\n\n <div className=\"checkout-login-form__customer-email\">\n {customer.email}\n </div>\n </div>\n ) : (\n <div className=\"checkout-login-form__content\">\n <form\n {...props}\n noValidate\n className={classes(['dropin-login-form__form', className])}\n name={name}\n >\n {/* Prevent 'Enter' key press from submitting this form. */}\n <button\n disabled\n aria-hidden=\"true\"\n style=\"display: none\"\n type=\"submit\"\n />\n <Email\n error={error}\n hint={hint as any}\n value={email}\n onBlur={onEmailBlur}\n onChange={onEmailChange}\n onInvalid={onEmailInvalid}\n />\n </form>\n </div>\n )}\n </div>\n );\n};\n\nexport const LoginForm = WithConditionals(\n LoginFormComponent,\n LoginFormSkeleton\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 { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\n\ninterface SignOutProps {\n onClick: (event: Event) => void;\n}\n\nexport const SignOut: FunctionComponent<SignOutProps> = ({ onClick }) => {\n const translations = useText({\n switch: 'Checkout.LoginForm.switch',\n signOut: 'Checkout.LoginForm.signOut'\n });\n\n return (\n <p className=\"checkout-login-form__sign-out\">\n {translations.switch}\n\n <a\n className=\"checkout-login-form__link\"\n href=\"#\"\n rel=\"noreferrer\"\n target=\"_blank\"\n onClick={(event) => {\n event.preventDefault();\n onClick?.(event);\n }}\n >\n {translations.signOut}\n </a>\n </p>\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 {\n getCustomer,\n isEmailAvailable,\n setGuestEmailOnCart,\n} from '@/checkout/api';\nimport {\n LoginForm as LoginFormComponent,\n SignIn,\n SignOut,\n} from '@/checkout/components/LoginForm';\nimport { Cart, Customer, NegotiableQuote } from '@/checkout/data/models';\nimport {\n getCartEmail,\n getLatestCheckoutUpdate,\n getValue,\n notifyValues,\n validateEmail,\n} from '@/checkout/lib';\nimport { TitleProps } from '@/checkout/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'preact/hooks';\n\ninterface ValidationError {\n email: string;\n message: string;\n type: 'missing' | 'invalid';\n}\n\ninterface CartSyncError {\n email: string;\n error: Error;\n}\n\nexport interface LoginFormProps\n extends HTMLAttributes<HTMLFormElement>,\n TitleProps {\n active?: boolean;\n autoSync?: boolean;\n displayHeadingContent?: boolean;\n onSignInClick?: (email: string) => void;\n onSignOutClick?: () => void;\n onCartSyncError?: (error: CartSyncError) => void;\n onValidationError?: (error: ValidationError) => void;\n slots?: {\n Heading?: SlotProps<{\n authenticated: boolean;\n }>;\n } & TitleProps['slots'];\n}\n\nconst DEBOUNCE_TIME = 1000;\n\nexport const LoginForm: Container<LoginFormProps> = ({\n active = true,\n autoSync = true,\n displayHeadingContent = true,\n displayTitle = true,\n initialData,\n onCartSyncError,\n onSignInClick,\n onSignOutClick,\n onValidationError,\n slots,\n ...props\n}) => {\n const [customer, setCustomer] = useState<Customer | null>(null);\n const [email, setEmail] = useState<string>('');\n const [error, setError] = useState<string>('');\n const [isAuthenticated, setIsAuthenticated] = useState(false);\n const [isAvailable, setIsAvailable] = useState<boolean>(true);\n const [isInitialized, setIsInitialized] = useState<boolean>(false);\n\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const {\n alreadyHaveAccountHint,\n cartSyncError,\n defaultTitle,\n fasterCheckoutHint,\n invalidEmailError,\n missingEmailError,\n signInLabel,\n } = useText({\n alreadyHaveAccountHint: 'Checkout.LoginForm.emailExists.alreadyHaveAccount',\n cartSyncError: 'Checkout.LoginForm.cartSyncError',\n defaultTitle: 'Checkout.LoginForm.title',\n fasterCheckoutHint: 'Checkout.LoginForm.emailExists.forFasterCheckout',\n invalidEmailError: 'Checkout.LoginForm.invalidEmailError',\n missingEmailError: 'Checkout.LoginForm.missingEmailError',\n signInLabel: 'Checkout.LoginForm.emailExists.signInButton',\n });\n\n const setEmailAndCheckAvailability = useCallback(\n (email: string) => {\n if (!validateEmail(email) || email === getCartEmail()) return;\n\n isEmailAvailable(email)\n .then((availability) => {\n setIsAvailable(availability);\n })\n .catch((error) => {\n console.error(error);\n setIsAvailable(true);\n });\n\n if (!autoSync) return;\n\n setGuestEmailOnCart(email).catch((error) => {\n onCartSyncError?.({ email, error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [autoSync, onCartSyncError, cartSyncError]\n );\n\n const handleChange = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const email = target.value;\n\n setEmail(email);\n setIsAvailable(true);\n setError('');\n\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current);\n }\n\n debounceTimer.current = setTimeout(() => {\n setEmailAndCheckAvailability(email);\n notifyValues({ email });\n debounceTimer.current = null;\n }, DEBOUNCE_TIME);\n },\n [setEmailAndCheckAvailability]\n );\n\n const handleBlur = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const email = target.value.trim();\n const isValid = validateEmail(email);\n\n if (isValid) {\n setError('');\n target.setCustomValidity('');\n\n if (!debounceTimer.current) return;\n\n clearTimeout(debounceTimer.current);\n debounceTimer.current = null;\n setEmailAndCheckAvailability(email);\n notifyValues({ email });\n return;\n }\n\n const type = email === '' ? 'missing' : 'invalid';\n const message =\n type === 'missing' ? missingEmailError : invalidEmailError;\n\n if (onValidationError) {\n onValidationError({ email, message, type });\n return;\n }\n\n setError(message);\n target.setCustomValidity(message);\n },\n [\n invalidEmailError,\n missingEmailError,\n onValidationError,\n setEmailAndCheckAvailability,\n ]\n );\n\n const handleInvalid = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const validity = target.validity;\n\n const message = validity.valueMissing\n ? missingEmailError\n : invalidEmailError;\n\n if (!onValidationError) {\n setError(message);\n return;\n }\n\n onValidationError({\n email: target.value,\n message,\n type: validity.valueMissing ? 'missing' : 'invalid',\n });\n },\n [missingEmailError, invalidEmailError, onValidationError]\n );\n\n const handleSignIn = useCallback(() => {\n const email = getValue('email') ?? '';\n const isValid = validateEmail(email);\n onSignInClick?.(isValid ? email : '');\n }, [onSignInClick]);\n\n const handleSignOut = useCallback(() => {\n onSignOutClick?.();\n }, [onSignOutClick]);\n\n const handleCheckoutData = useCallback((data: Cart | NegotiableQuote | null) => {\n const prevEmail = getValue('email') ?? '';\n const email = data?.email ?? '';\n\n if (email !== prevEmail) {\n setEmail(email);\n setError('');\n setIsAvailable(true);\n notifyValues({ email });\n }\n }, []);\n\n useEffect(() => {\n if (!active) return;\n\n const onAuthenticated = events.on(\n 'authenticated',\n (authenticated) => {\n setIsAuthenticated(authenticated);\n\n getCustomer()\n .then((customer) => {\n setCustomer(customer);\n })\n .catch(console.error);\n },\n { eager: true }\n );\n\n return () => {\n onAuthenticated?.off();\n };\n }, [active]);\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 local state from checkout data\n const checkoutEmail = pastUpdate.email ?? '';\n if (checkoutEmail) {\n setEmail(checkoutEmail);\n }\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n (data) => {\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 titleContent = useMemo(() => {\n if (!displayTitle) return undefined;\n\n return (\n <Slot name=\"checkout-login-form-title\" slot={slots?.Title}>\n <h2>{defaultTitle}</h2>\n </Slot>\n );\n }, [displayTitle, slots, defaultTitle]);\n\n const headingContent = useMemo(() => {\n if (!displayHeadingContent) return undefined;\n\n return (\n <Slot\n context={{ authenticated: isAuthenticated }}\n name=\"checkout-login-form-heading-label\"\n slot={slots?.Heading}\n >\n {isAuthenticated ? (\n <SignOut onClick={handleSignOut} />\n ) : (\n <SignIn onClick={handleSignIn} />\n )}\n </Slot>\n );\n }, [\n displayHeadingContent,\n isAuthenticated,\n slots,\n handleSignIn,\n handleSignOut,\n ]);\n\n const hintContent = useMemo(() => {\n if (isAvailable) return '';\n\n return (\n <>\n {alreadyHaveAccountHint}{' '}\n <a href=\"#\" onClick={handleSignIn}>\n {signInLabel}\n </a>{' '}\n {fasterCheckoutHint}\n </>\n );\n }, [\n isAvailable,\n alreadyHaveAccountHint,\n signInLabel,\n fasterCheckoutHint,\n handleSignIn,\n ]);\n\n return (\n <LoginFormComponent\n {...props}\n customer={customer}\n email={email}\n error={error}\n headingContent={headingContent}\n hint={hintContent}\n initialized={isInitialized}\n title={titleContent}\n visible={active}\n onEmailBlur={handleBlur}\n onEmailChange={handleChange}\n onEmailInvalid={handleInvalid}\n />\n );\n};\n"],"names":["Email","value","error","hint","onChange","onBlur","onInvalid","translations","useText","jsx","Field","Input","SignIn","onClick","jsxs","event","LoginFormSkeleton","Skeleton","SkeletonRow","LoginFormComponent","className","customer","email","headingContent","name","onEmailBlur","onEmailChange","onEmailInvalid","title","props","VComponent","classes","LoginForm","WithConditionals","SignOut","DEBOUNCE_TIME","active","autoSync","displayHeadingContent","displayTitle","initialData","onCartSyncError","onSignInClick","onSignOutClick","onValidationError","slots","setCustomer","useState","setEmail","setError","isAuthenticated","setIsAuthenticated","isAvailable","setIsAvailable","isInitialized","setIsInitialized","debounceTimer","useRef","alreadyHaveAccountHint","cartSyncError","defaultTitle","fasterCheckoutHint","invalidEmailError","missingEmailError","signInLabel","setEmailAndCheckAvailability","useCallback","validateEmail","getCartEmail","isEmailAvailable","availability","setGuestEmailOnCart","handleChange","notifyValues","handleBlur","target","type","message","handleInvalid","validity","handleSignIn","getValue","isValid","handleSignOut","handleCheckoutData","data","prevEmail","useEffect","onAuthenticated","events","authenticated","getCustomer","pastUpdate","getLatestCheckoutUpdate","checkoutEmail","onCheckoutInit","onCheckoutUpdated","titleContent","useMemo","Slot","hintContent","Fragment"],"mappings":"wsCA+BO,MAAMA,GAA4C,CAAC,CACxD,MAAAC,EACA,MAAAC,EACA,KAAAC,EACA,SAAAC,EACA,OAAAC,EACA,UAAAC,CACF,IAAM,CACJ,MAAMC,EAAeC,EAAQ,CAC3B,eAAgB,+BAChB,uBAAwB,mCACxB,qBAAsB,gCAAA,CACvB,EAGC,OAAAC,EAACC,GAAM,CAAA,MAAAR,EAAc,KAAAC,EACnB,SAAAM,EAACE,GAAA,CACC,aAAYJ,EAAa,eACzB,gBAAe,GACf,aAAa,QACb,cAAeA,EAAa,uBAC5B,GAAG,iBACH,KAAK,iBACL,YAAaA,EAAa,qBAC1B,SAAU,GACV,KAAK,QACL,MAAAN,EACA,OAAAI,EACA,SAAAD,EACA,UAAAE,CAAA,CAAA,EAEJ,CAEJ,ECxCaM,GAAyC,CAAC,CAAE,QAAAC,KAAc,CACrE,MAAMN,EAAeC,EAAQ,CAC3B,QAAS,6BACT,OAAQ,2BAAA,CACT,EAGC,OAAAM,EAAC,MAAI,CAAA,UAAU,+BACZ,SAAA,CAAaP,EAAA,QAEdE,EAAC,IAAA,CACC,UAAU,4BACV,cAAY,eACZ,KAAK,IACL,IAAI,aACJ,OAAO,SACP,QAAUM,GAAU,CAClBA,EAAM,eAAe,EACrBF,EAAQE,CAAK,CACf,EAEC,SAAaR,EAAA,MAAA,CAAA,CAChB,EACF,CAEJ,EC7BaS,GAAuC,IAEhDF,EAACG,GAAS,CAAA,cAAY,sBACpB,SAAA,CAAAR,EAACS,EAAY,CAAA,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CACD,EAGC,OAAAvE,EAACU,GAAA,CACE,GAAGU,EACJ,SAAAR,EACA,MAAAC,EACA,MAAApB,EACA,eAAAqB,GACA,KAAM6E,GACN,YAAa9C,GACb,MAAO2C,GACP,QAAS7D,EACT,YAAasC,GACb,cAAeF,GACf,eAAgBM,EAAA,CAClB,CAEJ"}
1
+ {"version":3,"file":"LoginForm.js","sources":["/@dropins/storefront-checkout/src/components/LoginForm/Email.tsx","/@dropins/storefront-checkout/src/components/LoginForm/SignIn.tsx","/@dropins/storefront-checkout/src/components/LoginForm/LoginFormSkeleton.tsx","/@dropins/storefront-checkout/src/components/LoginForm/LoginForm.tsx","/@dropins/storefront-checkout/src/components/LoginForm/SignOut.tsx","/@dropins/storefront-checkout/src/containers/LoginForm/LoginForm.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 { Field, Input } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface LoginEmailProps extends HTMLAttributes<HTMLInputElement> {\n value: string;\n error: string;\n hint: string;\n onChange: (event: Event) => void;\n onBlur: (event: Event) => void;\n onInvalid: (event: Event) => void;\n}\n\nexport const Email: FunctionComponent<LoginEmailProps> = ({\n value,\n error,\n hint,\n onChange,\n onBlur,\n onInvalid,\n}) => {\n const translations = useText({\n LoginFormLabel: 'Checkout.LoginForm.ariaLabel',\n LoginFormFloatingLabel: 'Checkout.LoginForm.floatingLabel',\n LoginFormPlaceholder: 'Checkout.LoginForm.placeholder',\n });\n\n return (\n <Field error={error} hint={hint}>\n <Input\n aria-label={translations.LoginFormLabel}\n aria-required={true}\n autocomplete=\"email\"\n floatingLabel={translations.LoginFormFloatingLabel}\n id=\"customer-email\"\n name=\"customer-email\"\n placeholder={translations.LoginFormPlaceholder}\n required={true}\n type=\"email\"\n value={value}\n onBlur={onBlur}\n onChange={onChange}\n onInvalid={onInvalid}\n />\n </Field>\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 { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\n\ninterface SignInProps {\n onClick: (event: Event) => void;\n}\n\nexport const SignIn: FunctionComponent<SignInProps> = ({ onClick }) => {\n const translations = useText({\n account: 'Checkout.LoginForm.account',\n signIn: 'Checkout.LoginForm.signIn'\n });\n\n return (\n <div className=\"checkout-login-form__sign-in\">\n {translations.account}\n\n <a\n className=\"checkout-login-form__link\"\n data-testid=\"sign-in-link\"\n href=\"#\"\n rel=\"noreferrer\"\n target=\"_blank\"\n onClick={(event) => {\n event.preventDefault();\n onClick(event);\n }}\n >\n {translations.signIn}\n </a>\n </div>\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 { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const LoginFormSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"login-form-skeleton\">\n <SkeletonRow fullWidth={true} variant=\"heading\" />\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 { Email } from '@/checkout/components';\nimport { WithConditionals } from '@/checkout/components/ConditionalWrapper/ConditionalWrapper';\nimport '@/checkout/components/LoginForm/LoginForm.css';\nimport { LoginFormSkeleton } from '@/checkout/components/LoginForm/LoginFormSkeleton';\nimport { Customer } from '@/checkout/data/models';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface LoginFormProps\n extends Omit<HTMLAttributes<HTMLFormElement>, 'title'> {\n customer: Customer | null;\n email: string;\n error: string;\n headingContent?: VNode;\n hint: string | VNode;\n onEmailBlur: (event: Event) => void;\n onEmailChange: (event: Event) => void;\n onEmailInvalid: (event: Event) => void;\n preferences?: VNode;\n title?: VNode;\n}\n\nconst LoginFormComponent: FunctionComponent<LoginFormProps> = ({\n className,\n customer,\n email,\n error,\n headingContent,\n hint,\n name,\n onEmailBlur,\n onEmailChange,\n onEmailInvalid,\n preferences,\n title,\n ...props\n}) => {\n return (\n <div className=\"checkout-login-form\" data-testid=\"checkout-login-form\">\n <div className=\"checkout-login-form__heading\">\n {title && (\n <VComponent className=\"checkout-login-form__title\" node={title} />\n )}\n\n {headingContent && (\n <VComponent\n className=\"checkout-login-form__heading-label\"\n node={headingContent}\n />\n )}\n </div>\n\n {customer ? (\n <div className=\"checkout-login-form__customer-details\">\n <div className=\"checkout-login-form__customer-name\">\n {`${customer.firstName} ${customer.lastName}`}\n </div>\n\n <div className=\"checkout-login-form__customer-email\">\n {customer.email}\n </div>\n </div>\n ) : (\n <div className=\"checkout-login-form__content\">\n <form\n {...props}\n noValidate\n className={classes(['dropin-login-form__form', className])}\n name={name}\n >\n {/* Prevent 'Enter' key press from submitting this form. */}\n <button\n disabled\n aria-hidden=\"true\"\n style=\"display: none\"\n type=\"submit\"\n />\n <Email\n error={error}\n hint={hint as any}\n value={email}\n onBlur={onEmailBlur}\n onChange={onEmailChange}\n onInvalid={onEmailInvalid}\n />\n {preferences && (\n <VComponent\n className=\"checkout-login-form__preferences\"\n node={preferences}\n />\n )}\n </form>\n </div>\n )}\n </div>\n );\n};\n\nexport const LoginForm = WithConditionals(\n LoginFormComponent,\n LoginFormSkeleton\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 { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\n\ninterface SignOutProps {\n onClick: (event: Event) => void;\n}\n\nexport const SignOut: FunctionComponent<SignOutProps> = ({ onClick }) => {\n const translations = useText({\n switch: 'Checkout.LoginForm.switch',\n signOut: 'Checkout.LoginForm.signOut'\n });\n\n return (\n <p className=\"checkout-login-form__sign-out\">\n {translations.switch}\n\n <a\n className=\"checkout-login-form__link\"\n href=\"#\"\n rel=\"noreferrer\"\n target=\"_blank\"\n onClick={(event) => {\n event.preventDefault();\n onClick?.(event);\n }}\n >\n {translations.signOut}\n </a>\n </p>\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 {\n getCustomer,\n isEmailAvailable,\n setGuestEmailOnCart,\n} from '@/checkout/api';\nimport {\n LoginForm as LoginFormComponent,\n SignIn,\n SignOut,\n} from '@/checkout/components/LoginForm';\nimport { Cart, Customer, NegotiableQuote } from '@/checkout/data/models';\nimport {\n getCartEmail,\n getLatestCheckoutUpdate,\n getValue,\n notifyValues,\n validateEmail,\n} from '@/checkout/lib';\nimport { TitleProps } from '@/checkout/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'preact/hooks';\n\ninterface ValidationError {\n email: string;\n message: string;\n type: 'missing' | 'invalid';\n}\n\ninterface CartSyncError {\n email: string;\n error: Error;\n}\n\nexport interface LoginFormProps\n extends HTMLAttributes<HTMLFormElement>,\n TitleProps {\n active?: boolean;\n autoSync?: boolean;\n displayHeadingContent?: boolean;\n onSignInClick?: (email: string) => void;\n onSignOutClick?: () => void;\n onCartSyncError?: (error: CartSyncError) => void;\n onValidationError?: (error: ValidationError) => void;\n slots?: {\n Heading?: SlotProps<{\n authenticated: boolean;\n }>;\n Preferences?: SlotProps<{\n email: string;\n isEmailValid: boolean;\n isAuthenticated: boolean;\n }>;\n } & TitleProps['slots'];\n}\n\nconst DEBOUNCE_TIME = 1000;\n\nexport const LoginForm: Container<LoginFormProps> = ({\n active = true,\n autoSync = true,\n displayHeadingContent = true,\n displayTitle = true,\n initialData,\n onCartSyncError,\n onSignInClick,\n onSignOutClick,\n onValidationError,\n slots,\n ...props\n}) => {\n const [customer, setCustomer] = useState<Customer | null>(null);\n const [email, setEmail] = useState<string>('');\n const [error, setError] = useState<string>('');\n const [isAuthenticated, setIsAuthenticated] = useState(false);\n const [isAvailable, setIsAvailable] = useState<boolean>(true);\n const [isInitialized, setIsInitialized] = useState<boolean>(false);\n\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const {\n alreadyHaveAccountHint,\n cartSyncError,\n defaultTitle,\n fasterCheckoutHint,\n invalidEmailError,\n missingEmailError,\n signInLabel,\n } = useText({\n alreadyHaveAccountHint: 'Checkout.LoginForm.emailExists.alreadyHaveAccount',\n cartSyncError: 'Checkout.LoginForm.cartSyncError',\n defaultTitle: 'Checkout.LoginForm.title',\n fasterCheckoutHint: 'Checkout.LoginForm.emailExists.forFasterCheckout',\n invalidEmailError: 'Checkout.LoginForm.invalidEmailError',\n missingEmailError: 'Checkout.LoginForm.missingEmailError',\n signInLabel: 'Checkout.LoginForm.emailExists.signInButton',\n });\n\n const setEmailAndCheckAvailability = useCallback(\n (email: string) => {\n if (!validateEmail(email) || email === getCartEmail()) return;\n\n isEmailAvailable(email)\n .then((availability) => {\n setIsAvailable(availability);\n })\n .catch((error) => {\n console.error(error);\n setIsAvailable(true);\n });\n\n if (!autoSync) return;\n\n setGuestEmailOnCart(email).catch((error) => {\n onCartSyncError?.({ email, error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [autoSync, onCartSyncError, cartSyncError]\n );\n\n const handleChange = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const email = target.value;\n\n setEmail(email);\n setIsAvailable(true);\n setError('');\n\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current);\n }\n\n debounceTimer.current = setTimeout(() => {\n setEmailAndCheckAvailability(email);\n notifyValues({ email });\n debounceTimer.current = null;\n }, DEBOUNCE_TIME);\n },\n [setEmailAndCheckAvailability]\n );\n\n const handleBlur = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const email = target.value.trim();\n const isValid = validateEmail(email);\n\n if (isValid) {\n setError('');\n target.setCustomValidity('');\n\n if (!debounceTimer.current) return;\n\n clearTimeout(debounceTimer.current);\n debounceTimer.current = null;\n setEmailAndCheckAvailability(email);\n notifyValues({ email });\n return;\n }\n\n const type = email === '' ? 'missing' : 'invalid';\n const message =\n type === 'missing' ? missingEmailError : invalidEmailError;\n\n if (onValidationError) {\n onValidationError({ email, message, type });\n return;\n }\n\n setError(message);\n target.setCustomValidity(message);\n },\n [\n invalidEmailError,\n missingEmailError,\n onValidationError,\n setEmailAndCheckAvailability,\n ]\n );\n\n const handleInvalid = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const validity = target.validity;\n\n const message = validity.valueMissing\n ? missingEmailError\n : invalidEmailError;\n\n if (!onValidationError) {\n setError(message);\n return;\n }\n\n onValidationError({\n email: target.value,\n message,\n type: validity.valueMissing ? 'missing' : 'invalid',\n });\n },\n [missingEmailError, invalidEmailError, onValidationError]\n );\n\n const handleSignIn = useCallback(() => {\n const email = getValue('email') ?? '';\n const isValid = validateEmail(email);\n onSignInClick?.(isValid ? email : '');\n }, [onSignInClick]);\n\n const handleSignOut = useCallback(() => {\n onSignOutClick?.();\n }, [onSignOutClick]);\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const prevEmail = getValue('email') ?? '';\n const email = data?.email ?? '';\n\n if (email !== prevEmail) {\n setEmail(email);\n setError('');\n setIsAvailable(true);\n notifyValues({ email });\n }\n },\n []\n );\n\n useEffect(() => {\n if (!active) return;\n\n const onAuthenticated = events.on(\n 'authenticated',\n (authenticated) => {\n setIsAuthenticated(authenticated);\n\n getCustomer()\n .then((customer) => {\n setCustomer(customer);\n })\n .catch(console.error);\n },\n { eager: true }\n );\n\n return () => {\n onAuthenticated?.off();\n };\n }, [active]);\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 local state from checkout data\n const checkoutEmail = pastUpdate.email ?? '';\n if (checkoutEmail) {\n setEmail(checkoutEmail);\n }\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n (data) => {\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 titleContent = useMemo(() => {\n if (!displayTitle) return undefined;\n\n return (\n <Slot name=\"checkout-login-form-title\" slot={slots?.Title}>\n <h2>{defaultTitle}</h2>\n </Slot>\n );\n }, [displayTitle, slots, defaultTitle]);\n\n const headingContent = useMemo(() => {\n if (!displayHeadingContent) return undefined;\n\n return (\n <Slot\n context={{ authenticated: isAuthenticated }}\n name=\"checkout-login-form-heading-label\"\n slot={slots?.Heading}\n >\n {isAuthenticated ? (\n <SignOut onClick={handleSignOut} />\n ) : (\n <SignIn onClick={handleSignIn} />\n )}\n </Slot>\n );\n }, [\n displayHeadingContent,\n isAuthenticated,\n slots,\n handleSignIn,\n handleSignOut,\n ]);\n\n const hintContent = useMemo(() => {\n if (isAvailable) return '';\n\n return (\n <>\n {alreadyHaveAccountHint}{' '}\n <a href=\"#\" onClick={handleSignIn}>\n {signInLabel}\n </a>{' '}\n {fasterCheckoutHint}\n </>\n );\n }, [\n isAvailable,\n alreadyHaveAccountHint,\n signInLabel,\n fasterCheckoutHint,\n handleSignIn,\n ]);\n\n const preferencesContent = useMemo(() => {\n return (\n <Slot\n context={{\n email,\n isEmailValid: validateEmail(email),\n isAuthenticated,\n }}\n name=\"checkout-login-form-preferences\"\n slot={slots?.Preferences}\n />\n );\n }, [email, isAuthenticated, slots]);\n\n return (\n <LoginFormComponent\n {...props}\n customer={customer}\n email={email}\n error={error}\n headingContent={headingContent}\n hint={hintContent}\n initialized={isInitialized}\n preferences={preferencesContent}\n title={titleContent}\n visible={active}\n onEmailBlur={handleBlur}\n onEmailChange={handleChange}\n onEmailInvalid={handleInvalid}\n />\n );\n};\n"],"names":["Email","value","error","hint","onChange","onBlur","onInvalid","translations","useText","jsx","Field","Input","SignIn","onClick","jsxs","event","LoginFormSkeleton","Skeleton","SkeletonRow","LoginFormComponent","className","customer","email","headingContent","name","onEmailBlur","onEmailChange","onEmailInvalid","preferences","title","props","VComponent","classes","LoginForm","WithConditionals","SignOut","DEBOUNCE_TIME","active","autoSync","displayHeadingContent","displayTitle","initialData","onCartSyncError","onSignInClick","onSignOutClick","onValidationError","slots","setCustomer","useState","setEmail","setError","isAuthenticated","setIsAuthenticated","isAvailable","setIsAvailable","isInitialized","setIsInitialized","debounceTimer","useRef","alreadyHaveAccountHint","cartSyncError","defaultTitle","fasterCheckoutHint","invalidEmailError","missingEmailError","signInLabel","setEmailAndCheckAvailability","useCallback","validateEmail","getCartEmail","isEmailAvailable","availability","setGuestEmailOnCart","handleChange","notifyValues","handleBlur","target","type","message","handleInvalid","validity","handleSignIn","getValue","isValid","handleSignOut","handleCheckoutData","data","prevEmail","useEffect","onAuthenticated","events","authenticated","getCustomer","pastUpdate","getLatestCheckoutUpdate","checkoutEmail","onCheckoutInit","onCheckoutUpdated","titleContent","useMemo","Slot","hintContent","Fragment","preferencesContent"],"mappings":"wsCA+BO,MAAMA,GAA4C,CAAC,CACxD,MAAAC,EACA,MAAAC,EACA,KAAAC,EACA,SAAAC,EACA,OAAAC,EACA,UAAAC,CACF,IAAM,CAC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ACb,YAAagD,GACb,MAAOL,GACP,QAAS7D,EACT,YAAasC,GACb,cAAeF,GACf,eAAgBM,EAAA,CAClB,CAEJ"}
@@ -4,7 +4,10 @@ export declare enum HandlerCode {
4
4
  PaymentOnAccount = "companycredit",
5
5
  PurchaseOrder = "purchaseorder"
6
6
  }
7
- export declare const handleRefNumberChange: (code: string, isRequired: boolean) => (this: any, ...args: any[]) => void;
7
+ export declare const handleRefNumberChange: (code: string, isRequired: boolean) => {
8
+ (this: any, ...args: any[]): void;
9
+ cancel(): void;
10
+ };
8
11
  export declare const resetHandlersCache: () => void;
9
12
  export declare const createHandler: (code: HandlerCode) => PaymentMethodConfig;
10
13
  export declare const defaultHandlers: {
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{h as se,s as ie}from"../chunks/fetch-graphql.js";import{classes as O,VComponent as me,deepmerge as de,Slot as G}from"@dropins/tools/lib.js";import{events as q}from"@dropins/tools/event-bus.js";import{v as le}from"../chunks/validation.js";import{s as Q}from"../chunks/setPaymentMethod.js";import{jsxs as D,jsx as c}from"@dropins/tools/preact-jsx-runtime.js";import{useState as _,useMemo as L,useCallback as p,useEffect as R}from"@dropins/tools/preact-hooks.js";import"../chunks/TermsAndConditions.js";import{Skeleton as ue,SkeletonRow as N,IllustratedMessage as pe,Icon as X,InLineAlert as he,ToggleButton as fe,RadioButton as ye}from"@dropins/tools/components.js";/* empty css */import*as T from"@dropins/tools/preact-compat.js";import{useRef as ke,useEffect as ge}from"@dropins/tools/preact-compat.js";/* empty css *//* empty css *//* empty css *//* empty css */import{P as ve}from"../chunks/PurchaseOrder.js";import{P as Ce}from"../chunks/PaymentOnAccount2.js";import{r as Se}from"../chunks/render.js";import{i as Me}from"../chunks/events.js";import{h as be,a as Ee}from"../chunks/events2.js";import{g as V,n as Pe}from"../chunks/values.js";import{W as we}from"../chunks/ConditionalWrapper.js";import{s as _e}from"../chunks/dom.js";import{useText as Y}from"@dropins/tools/i18n.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/guards.js";import"../chunks/synchronizeCheckout.js";import"../chunks/transform-shipping-methods.js";import"../chunks/classifiers.js";import"../chunks/getCompanyCredit.js";const Ne=e=>T.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},T.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"}),T.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),T.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),Te=()=>D(ue,{"data-testid":"payment-methods-skeleton",children:[c(N,{size:"medium",variant:"heading"}),c(N,{size:"medium",variant:"empty"}),c(N,{fullWidth:!0,size:"xlarge"}),c(N,{fullWidth:!0,size:"xlarge"})]}),Ie=({UIComponentType:e="ToggleButton",busy:r,code:a,icon:i,onSelectionChange:o,selected:s,title:m})=>{const u={busy:r,className:"checkout-payment-methods__method",label:m,name:"payment-method",onChange:()=>o({code:a,title:m}),value:a};return e==="ToggleButton"?c(fe,{...u,icon:i?c(X,{source:i}):void 0,selected:s}):c(ye,{...u,checked:s,icon:i??void 0})},He=({className:e,error:r=null,busy:a=!1,onDismissError:i,onSelectionChange:o=()=>{},options:s,paymentMethodContent:m,selection:u,title:f,UIComponentType:S})=>{const v=Y({EmptyState:"Checkout.PaymentMethods.emptyState"}),d=r!==null,C=ke(null);return ge(()=>{d&&C.current&&_e(C.current)},[d]),D("div",{className:O(["checkout-payment-methods",e]),"data-testid":"checkout-payment-methods",children:[f&&c(me,{className:"checkout-payment-methods__title",node:f}),!a&&s.length===0&&c(pe,{"data-testid":"checkout-payment-methods-empty",icon:c(X,{source:Ne}),message:c("p",{children:v.EmptyState})}),D("div",{className:O(["checkout-payment-methods__wrapper",["checkout-payment-methods__wrapper--busy",a]]),"data-testid":"checkout-payment-methods-wrapper",children:[c("div",{className:O(["checkout-payment-methods__methods",["checkout-payment-methods--full-width",s.length%2!==0]]),children:s==null?void 0:s.map(y=>c(Ie,{UIComponentType:S,busy:a,code:y.code,icon:y.icon,selected:(u==null?void 0:u.code)===y.code,title:y.displayLabel??!0?y.title:"",onSelectionChange:o},y.code))}),m&&c("div",{className:"checkout-payment-methods__content",children:m})]}),d&&c("div",{ref:C,className:"checkout-payment-methods__error","data-testid":"checkout-payment-methods-alert",children:c(he,{heading:r,type:"error",variant:"primary",onDismiss:i})})]})},Oe=we(He,Te),Le=(e,r)=>{let a;return function(...i){clearTimeout(a),a=setTimeout(()=>e.apply(this,i),r)}};var Re=(e=>(e.PaymentOnAccount="companycredit",e.PurchaseOrder="purchaseorder",e))(Re||{});const J={companycredit:{Container:Ce,autoSync:!0,formName:"payment-on-account",validateRefNumber:!1},purchaseorder:{Container:ve,autoSync:!1,formName:"purchase-order",validateRefNumber:!0}},I=new Map,Ve=(e,r)=>{const a=`${e}-${r}`;if(!I.has(a)){const i=Le(async o=>{if(!r||le(o))try{await Q({code:e,purchase_order_number:o})}catch(s){console.error(`Failed to set payment method for ${e}:`,s)}},1e3);I.set(a,i)}return I.get(a)},w={},kt=()=>{Object.keys(w).forEach(e=>{delete w[e]}),I.clear()},K=e=>{if(!(e in J))throw new Error(`Invalid handler code: ${e}`);if(w[e])return w[e];const r=J[e],{autoSync:a,Container:i,formName:o,validateRefNumber:s}=r,m={enabled:!0,autoSync:a,render:u=>{var v;const f=String(((v=u.additionalData)==null?void 0:v.purchase_order_number)??""),S=document.createElement("div");Se.render(i,{name:o,initialReferenceNumber:f,onReferenceNumberChange:Ve(e,s)})(S),u.replaceHTML(S)}};return w[e]=m,m},Ae={companycredit:K("companycredit"),purchaseorder:K("purchaseorder")};function A(e,r){return e?r.some(a=>a.code===e.code):!1}function De(e,r){return!e||!r?!1:e.code===r.code}function We(e){return e?!!e.code&&!!e.title:!1}const gt=({UIComponentType:e="ToggleButton",active:r=!0,autoSync:a=!0,displayTitle:i=!0,slots:o,onCartSyncError:s,onSelectionChange:m})=>{const[u,f]=_(null),[S,v]=_(!1),[d,C]=_(null),[y,W]=_([]),ee=se.value,{cartSyncError:x,defaultTitle:z}=Y({cartSyncError:"Checkout.PaymentMethods.cartSyncError",defaultTitle:"Checkout.PaymentMethods.title"}),k=L(()=>{const t=(o==null?void 0:o.Methods)??{};return de(Ae,t)},[o==null?void 0:o.Methods]),U=p(t=>{var n;return(n=k[t.code])==null?void 0:n.render},[k]),B=p(t=>{const n=k[t.code];return n?n.autoSync!==!1:a},[a,k]),$=p(t=>{var l;return((l=k[t.code])==null?void 0:l.enabled)!==!1},[k]),te=p(t=>t.map(n=>{const l=k[n.code];return l?{...n,icon:l.icon}:n}),[k]),j=p(t=>{C(n=>n&&{...n,additionalData:t})},[]),ne=p(()=>{f(null)},[]),h=p(t=>{f(null),C(t)},[]),E=p(async(t,n)=>{(Me()||be())&&B(t)&&Q({code:t.code}).catch(g=>{h(n??null),f(s?null:x),s==null||s({method:t,error:g})})},[x,B,s,h]),re=p(async t=>{const n=V("selectedPaymentMethod");h(t),m==null||m(t),await E(t,n)},[m,h,E]),P=p(t=>{if(!t||t.isEmpty){h(null),W([]);return}const g=(t.availablePaymentMethods??[]).filter($);if(W(g),g.length===0){h(null);return}const M=t.selectedPaymentMethod??null,F=We(M),b=V("selectedPaymentMethod"),H=A(b,g),ce=De(b,M);if(b&&H&&!ce){E(b,M);return}if((!b||!H)&&F&&A(M,g)){h(M);return}if((!b||!H)&&(!F||!A(M,g))){const Z=g[0];h(Z),E(Z)}},[$,h,E]);R(()=>{if(!r)return;const t=Ee();if(t){v(!0);const l=V("selectedPaymentMethod");l&&C(l),P(t);return}const n=q.on("checkout/initialized",l=>{v(!0),P(l)},{eager:!0});return()=>{n==null||n.off()}},[r,P]),R(()=>{if(!r)return;const t=q.on("checkout/updated",P,{eager:!1});return()=>{t==null||t.off()}},[r,P]),R(()=>{Pe({selectedPaymentMethod:d})},[d]);const oe=L(()=>{if(i)return c(G,{name:"checkout-payment-methods-title",slot:o==null?void 0:o.Title,children:c("h2",{children:z})})},[i,o==null?void 0:o.Title,z]),ae=L(()=>{if(!d)return;const t=U(d);if(t)return c(G,{context:{additionalData:d.additionalData,cartId:ie.cartId??"",replaceHTML(n){this.replaceWith(n)},setAdditionalData:j},name:"PaymentMethodContent",slot:t},d.code)},[U,d,j]);return c(Oe,{UIComponentType:e,busy:ee,error:u,initialized:S,options:te(y),paymentMethodContent:ae,selection:d,title:oe,visible:r,onDismissError:ne,onSelectionChange:re})};export{Re as HandlerCode,gt as PaymentMethods,K as createHandler,gt as default,Ae as defaultHandlers,Ve as handleRefNumberChange,kt as resetHandlersCache};
3
+ import{h as se,s as ie}from"../chunks/fetch-graphql.js";import{classes as O,VComponent as me,deepmerge as de,Slot as G}from"@dropins/tools/lib.js";import{events as q}from"@dropins/tools/event-bus.js";import{v as le}from"../chunks/validation.js";import{s as Q}from"../chunks/setPaymentMethod.js";import{jsxs as D,jsx as c}from"@dropins/tools/preact-jsx-runtime.js";import{useState as T,useMemo as L,useCallback as p,useEffect as R}from"@dropins/tools/preact-hooks.js";import"../chunks/TermsAndConditions.js";import{Skeleton as ue,SkeletonRow as _,IllustratedMessage as pe,Icon as X,InLineAlert as he,ToggleButton as fe,RadioButton as ye}from"@dropins/tools/components.js";/* empty css */import*as N from"@dropins/tools/preact-compat.js";import{useRef as ke,useEffect as ge}from"@dropins/tools/preact-compat.js";/* empty css *//* empty css *//* empty css *//* empty css */import{P as ve}from"../chunks/PurchaseOrder.js";import{P as Ce}from"../chunks/PaymentOnAccount2.js";import{r as Se}from"../chunks/render.js";import{i as be}from"../chunks/events.js";import{h as Me,a as Ee}from"../chunks/events2.js";import{g as V,n as Pe}from"../chunks/values.js";import{W as we}from"../chunks/ConditionalWrapper.js";import{s as Te}from"../chunks/dom.js";import{useText as Y}from"@dropins/tools/i18n.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/guards.js";import"../chunks/synchronizeCheckout.js";import"../chunks/transform-shipping-methods.js";import"../chunks/classifiers.js";import"../chunks/getCompanyCredit.js";const _e=e=>N.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},N.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"}),N.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),N.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),Ne=()=>D(ue,{"data-testid":"payment-methods-skeleton",children:[c(_,{size:"medium",variant:"heading"}),c(_,{size:"medium",variant:"empty"}),c(_,{fullWidth:!0,size:"xlarge"}),c(_,{fullWidth:!0,size:"xlarge"})]}),Ie=({UIComponentType:e="ToggleButton",busy:o,code:a,icon:i,onSelectionChange:r,selected:s,title:m})=>{const u={busy:o,className:"checkout-payment-methods__method",label:m,name:"payment-method",onChange:()=>r({code:a,title:m}),value:a};return e==="ToggleButton"?c(fe,{...u,icon:i?c(X,{source:i}):void 0,selected:s}):c(ye,{...u,checked:s,icon:i??void 0})},He=({className:e,error:o=null,busy:a=!1,onDismissError:i,onSelectionChange:r=()=>{},options:s,paymentMethodContent:m,selection:u,title:f,UIComponentType:S})=>{const v=Y({EmptyState:"Checkout.PaymentMethods.emptyState"}),d=o!==null,C=ke(null);return ge(()=>{d&&C.current&&Te(C.current)},[d]),D("div",{className:O(["checkout-payment-methods",e]),"data-testid":"checkout-payment-methods",children:[f&&c(me,{className:"checkout-payment-methods__title",node:f}),!a&&s.length===0&&c(pe,{"data-testid":"checkout-payment-methods-empty",icon:c(X,{source:_e}),message:c("p",{children:v.EmptyState})}),D("div",{className:O(["checkout-payment-methods__wrapper",["checkout-payment-methods__wrapper--busy",a]]),"data-testid":"checkout-payment-methods-wrapper",children:[c("div",{className:O(["checkout-payment-methods__methods",["checkout-payment-methods--full-width",s.length%2!==0]]),children:s==null?void 0:s.map(y=>c(Ie,{UIComponentType:S,busy:a,code:y.code,icon:y.icon,selected:(u==null?void 0:u.code)===y.code,title:y.displayLabel??!0?y.title:"",onSelectionChange:r},y.code))}),m&&c("div",{className:"checkout-payment-methods__content",children:m})]}),d&&c("div",{ref:C,className:"checkout-payment-methods__error","data-testid":"checkout-payment-methods-alert",children:c(he,{heading:o,type:"error",variant:"primary",onDismiss:i})})]})},Oe=we(He,Ne),Le=(e,o)=>{let a;const i=function(...r){clearTimeout(a),a=setTimeout(()=>e.apply(this,r),o)};return i.cancel=()=>{clearTimeout(a)},i};var Re=(e=>(e.PaymentOnAccount="companycredit",e.PurchaseOrder="purchaseorder",e))(Re||{});const J={companycredit:{Container:Ce,autoSync:!0,formName:"payment-on-account",validateRefNumber:!1},purchaseorder:{Container:ve,autoSync:!1,formName:"purchase-order",validateRefNumber:!0}},I=new Map,Ve=(e,o)=>{const a=`${e}-${o}`;if(!I.has(a)){const i=Le(async r=>{if(!o||le(r))try{await Q({code:e,purchase_order_number:r})}catch(s){console.error(`Failed to set payment method for ${e}:`,s)}},1e3);I.set(a,i)}return I.get(a)},w={},kt=()=>{Object.keys(w).forEach(e=>{delete w[e]}),I.clear()},K=e=>{if(!(e in J))throw new Error(`Invalid handler code: ${e}`);if(w[e])return w[e];const o=J[e],{autoSync:a,Container:i,formName:r,validateRefNumber:s}=o,m={enabled:!0,autoSync:a,render:u=>{var v;const f=String(((v=u.additionalData)==null?void 0:v.purchase_order_number)??""),S=document.createElement("div");Se.render(i,{name:r,initialReferenceNumber:f,onReferenceNumberChange:Ve(e,s)})(S),u.replaceHTML(S)}};return w[e]=m,m},Ae={companycredit:K("companycredit"),purchaseorder:K("purchaseorder")};function A(e,o){return e?o.some(a=>a.code===e.code):!1}function De(e,o){return!e||!o?!1:e.code===o.code}function We(e){return e?!!e.code&&!!e.title:!1}const gt=({UIComponentType:e="ToggleButton",active:o=!0,autoSync:a=!0,displayTitle:i=!0,slots:r,onCartSyncError:s,onSelectionChange:m})=>{const[u,f]=T(null),[S,v]=T(!1),[d,C]=T(null),[y,W]=T([]),ee=se.value,{cartSyncError:x,defaultTitle:z}=Y({cartSyncError:"Checkout.PaymentMethods.cartSyncError",defaultTitle:"Checkout.PaymentMethods.title"}),k=L(()=>{const t=(r==null?void 0:r.Methods)??{};return de(Ae,t)},[r==null?void 0:r.Methods]),U=p(t=>{var n;return(n=k[t.code])==null?void 0:n.render},[k]),B=p(t=>{const n=k[t.code];return n?n.autoSync!==!1:a},[a,k]),$=p(t=>{var l;return((l=k[t.code])==null?void 0:l.enabled)!==!1},[k]),te=p(t=>t.map(n=>{const l=k[n.code];return l?{...n,icon:l.icon}:n}),[k]),j=p(t=>{C(n=>n&&{...n,additionalData:t})},[]),ne=p(()=>{f(null)},[]),h=p(t=>{f(null),C(t)},[]),E=p(async(t,n)=>{(be()||Me())&&B(t)&&Q({code:t.code}).catch(g=>{h(n??null),f(s?null:x),s==null||s({method:t,error:g})})},[x,B,s,h]),re=p(async t=>{const n=V("selectedPaymentMethod");h(t),m==null||m(t),await E(t,n)},[m,h,E]),P=p(t=>{if(!t||t.isEmpty){h(null),W([]);return}const g=(t.availablePaymentMethods??[]).filter($);if(W(g),g.length===0){h(null);return}const b=t.selectedPaymentMethod??null,F=We(b),M=V("selectedPaymentMethod"),H=A(M,g),ce=De(M,b);if(M&&H&&!ce){E(M,b);return}if((!M||!H)&&F&&A(b,g)){h(b);return}if((!M||!H)&&(!F||!A(b,g))){const Z=g[0];h(Z),E(Z)}},[$,h,E]);R(()=>{if(!o)return;const t=Ee();if(t){v(!0);const l=V("selectedPaymentMethod");l&&C(l),P(t);return}const n=q.on("checkout/initialized",l=>{v(!0),P(l)},{eager:!0});return()=>{n==null||n.off()}},[o,P]),R(()=>{if(!o)return;const t=q.on("checkout/updated",P,{eager:!1});return()=>{t==null||t.off()}},[o,P]),R(()=>{Pe({selectedPaymentMethod:d})},[d]);const oe=L(()=>{if(i)return c(G,{name:"checkout-payment-methods-title",slot:r==null?void 0:r.Title,children:c("h2",{children:z})})},[i,r==null?void 0:r.Title,z]),ae=L(()=>{if(!d)return;const t=U(d);if(t)return c(G,{context:{additionalData:d.additionalData,cartId:ie.cartId??"",replaceHTML(n){this.replaceWith(n)},setAdditionalData:j},name:"PaymentMethodContent",slot:t},d.code)},[U,d,j]);return c(Oe,{UIComponentType:e,busy:ee,error:u,initialized:S,options:te(y),paymentMethodContent:ae,selection:d,title:oe,visible:o,onDismissError:ne,onSelectionChange:re})};export{Re as HandlerCode,gt as PaymentMethods,K as createHandler,gt as default,Ae as defaultHandlers,Ve as handleRefNumberChange,kt as resetHandlersCache};
4
4
  //# sourceMappingURL=PaymentMethods.js.map
@@ -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';\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\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 getSlot = useCallback((method: PaymentMethod) => {\n return availableHandlers[method.code]?.render;\n }, [availableHandlers]);\n\n const hasAutoSyncEnabled = useCallback((method: PaymentMethod) => {\n const config = availableHandlers[method.code];\n if (!config) return autoSync;\n return config.autoSync !== false;\n }, [autoSync, availableHandlers]);\n\n const isEnabled = useCallback((method: PaymentMethod) => {\n const config = availableHandlers[method.code]?.enabled;\n return config !== false;\n }, [availableHandlers]);\n\n const withIcons = useCallback((options: PaymentMethod[]) => {\n return options.map((option) => {\n const handler = availableHandlers[option.code];\n if (!handler) return option;\n return {\n ...option,\n icon: handler.icon\n };\n });\n }, [availableHandlers]);\n\n const setAdditionalData = useCallback((additionalData: AdditionalData) => {\n setSelection((prev) => {\n if (!prev) return prev;\n return { ...prev, additionalData };\n });\n }, []);\n\n const handleDismissError = useCallback(() => {\n setError(null);\n }, []);\n\n const updateSelection = useCallback((selection: PaymentMethod | null) => {\n setError(null);\n setSelection(selection);\n }, []);\n\n const updateCartSelection = useCallback(\n async (selection: PaymentMethod, fallback?: PaymentMethod | null) => {\n const canSetSelectionOnCart = isVirtualCart() || hasShippingAddress();\n\n if (!canSetSelectionOnCart) return;\n if (!hasAutoSyncEnabled(selection)) return;\n\n setPaymentMethod({ code: selection.code }).catch((error) => {\n updateSelection(fallback ?? null);\n setError(onCartSyncError ? null : cartSyncError);\n onCartSyncError?.({ method: selection, error });\n });\n },\n [\n cartSyncError,\n hasAutoSyncEnabled,\n onCartSyncError,\n updateSelection,\n ]\n );\n\n const handleSelectionChange = useCallback(\n async (selection: PaymentMethod) => {\n const prevSelection = getValue('selectedPaymentMethod');\n updateSelection(selection);\n onSelectionChange?.(selection);\n await updateCartSelection(selection, prevSelection);\n },\n [onSelectionChange, updateSelection, updateCartSelection]\n );\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const isEmptyCart = !data || data.isEmpty;\n\n if (isEmptyCart) {\n updateSelection(null);\n setOptions([]);\n return;\n }\n\n const availableOptions = data.availablePaymentMethods ?? [];\n const enabledOptions = availableOptions.filter(isEnabled);\n\n setOptions(enabledOptions);\n\n if (enabledOptions.length === 0) {\n updateSelection(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, enabledOptions);\n const haveSameSelection = isEqual(userSelection, cartSelection);\n\n // User has valid selection that differs from cart\n if (userSelection && isUserSelectionAvailable && !haveSameSelection) {\n updateCartSelection(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, enabledOptions)\n ) {\n updateSelection(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, enabledOptions))\n ) {\n const newSelection = enabledOptions[0];\n updateSelection(newSelection);\n updateCartSelection(newSelection);\n }\n },\n [isEnabled, updateSelection, updateCartSelection]\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 useEffect(() => {\n notifyValues({ selectedPaymentMethod: selection });\n }, [selection]);\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 if (!selection) return;\n\n const slot = getSlot(selection);\n if (!slot) return;\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 }, [getSlot, selection, setAdditionalData]);\n\n return (\n <PaymentMethodsComponent\n UIComponentType={UIComponentType}\n busy={isBusy}\n error={error}\n initialized={isInitialized}\n options={withIcons(options)}\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","getSlot","useCallback","hasAutoSyncEnabled","isEnabled","withIcons","setAdditionalData","additionalData","prev","handleDismissError","updateSelection","updateCartSelection","fallback","isVirtualCart","hasShippingAddress","handleSelectionChange","prevSelection","getValue","handleCheckoutData","data","enabledOptions","cartSelection","hasCartSelection","userSelection","isUserSelectionAvailable","haveSameSelection","newSelection","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","events","onCheckoutUpdated","notifyValues","titleContent","Slot","slot","state","domElement"],"mappings":"ypDACA,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,CAAY,UAAW,GAAM,KAAK,QAAS,CAAA,CAAA,EAC9C,ECmCEC,GAAuD,CAAC,CAC5D,gBAAAC,EAAkB,eAClB,KAAAC,EACA,KAAAC,EACA,KAAAC,EACA,kBAAAC,EACA,SAAAC,EACA,MAAAC,CACF,IAAM,CACJ,MAAMC,EAAc,CAClB,KAAAN,EACA,UAAW,mCACX,MAAOK,EACP,KAAM,iBACN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D,EAAoBD,EAAO,GAC/B,mBACAZ,EACA,CAAE,MAAO,EAAM,CACjB,EAEA,MAAO,IAAM,CACXa,GAAA,MAAAA,EAAmB,KACrB,CAAA,EACC,CAAChD,EAAQmC,CAAkB,CAAC,EAE/BnF,EAAU,IAAM,CACDiG,GAAA,CAAE,sBAAuBvG,EAAW,CAAA,EAChD,CAACA,CAAS,CAAC,EAER,MAAAwG,GAAenC,EAAQ,IAAM,CAC7B,GAACd,EAGH,OAAA3E,EAAC6H,EAAK,CAAA,KAAK,iCAAiC,KAAMjD,GAAA,YAAAA,EAAO,MACvD,SAAA5E,EAAC,KAAI,CAAA,SAAAuF,CAAa,CAAA,EACpB,GAED,CAACZ,EAAcC,GAAA,YAAAA,EAAO,MAAOW,CAAY,CAAC,EAEvCpE,GAAuBsE,EAAQ,IAAM,CACzC,GAAI,CAACrE,EAAW,OAEV,MAAA0G,EAAOlC,EAAQxE,CAAS,EAC9B,GAAK0G,EAGH,OAAA9H,EAAC6H,EAAA,CAEC,QAAS,CACP,eAAgBzG,EAAW,eAC3B,OAAQ2G,GAAM,QAAU,GACxB,YAAYC,EAAyB,CACnC,KAAK,YAAYA,CAAU,CAC7B,EACA,kBAAA/B,CACF,EACA,KAAK,uBACL,KAAA6B,CAAA,EAVK1G,EAAW,IAWlB,CAGD,EAAA,CAACwE,EAASxE,EAAW6E,CAAiB,CAAC,EAGxC,OAAAjG,EAACc,GAAA,CACC,gBAAiBX,EACjB,KAAMiF,GACN,MAAApE,EACA,YAAagE,EACb,QAASgB,GAAU9E,CAAO,EAC1B,qBAAAC,GACA,UAAAC,EACA,MAAOwG,GACP,QAASlD,EACT,eAAgB0B,GAChB,kBAAmBM,EAAA,CACrB,CAEJ","x_google_ignoreList":[0,3]}
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 const debouncedFn = function (this: any, ...args: any[]) {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => fn.apply(this, args), ms);\n };\n debouncedFn.cancel = () => {\n clearTimeout(timeoutId);\n };\n return debouncedFn;\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\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 getSlot = useCallback((method: PaymentMethod) => {\n return availableHandlers[method.code]?.render;\n }, [availableHandlers]);\n\n const hasAutoSyncEnabled = useCallback((method: PaymentMethod) => {\n const config = availableHandlers[method.code];\n if (!config) return autoSync;\n return config.autoSync !== false;\n }, [autoSync, availableHandlers]);\n\n const isEnabled = useCallback((method: PaymentMethod) => {\n const config = availableHandlers[method.code]?.enabled;\n return config !== false;\n }, [availableHandlers]);\n\n const withIcons = useCallback((options: PaymentMethod[]) => {\n return options.map((option) => {\n const handler = availableHandlers[option.code];\n if (!handler) return option;\n return {\n ...option,\n icon: handler.icon\n };\n });\n }, [availableHandlers]);\n\n const setAdditionalData = useCallback((additionalData: AdditionalData) => {\n setSelection((prev) => {\n if (!prev) return prev;\n return { ...prev, additionalData };\n });\n }, []);\n\n const handleDismissError = useCallback(() => {\n setError(null);\n }, []);\n\n const updateSelection = useCallback((selection: PaymentMethod | null) => {\n setError(null);\n setSelection(selection);\n }, []);\n\n const updateCartSelection = useCallback(\n async (selection: PaymentMethod, fallback?: PaymentMethod | null) => {\n const canSetSelectionOnCart = isVirtualCart() || hasShippingAddress();\n\n if (!canSetSelectionOnCart) return;\n if (!hasAutoSyncEnabled(selection)) return;\n\n setPaymentMethod({ code: selection.code }).catch((error) => {\n updateSelection(fallback ?? null);\n setError(onCartSyncError ? null : cartSyncError);\n onCartSyncError?.({ method: selection, error });\n });\n },\n [\n cartSyncError,\n hasAutoSyncEnabled,\n onCartSyncError,\n updateSelection,\n ]\n );\n\n const handleSelectionChange = useCallback(\n async (selection: PaymentMethod) => {\n const prevSelection = getValue('selectedPaymentMethod');\n updateSelection(selection);\n onSelectionChange?.(selection);\n await updateCartSelection(selection, prevSelection);\n },\n [onSelectionChange, updateSelection, updateCartSelection]\n );\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const isEmptyCart = !data || data.isEmpty;\n\n if (isEmptyCart) {\n updateSelection(null);\n setOptions([]);\n return;\n }\n\n const availableOptions = data.availablePaymentMethods ?? [];\n const enabledOptions = availableOptions.filter(isEnabled);\n\n setOptions(enabledOptions);\n\n if (enabledOptions.length === 0) {\n updateSelection(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, enabledOptions);\n const haveSameSelection = isEqual(userSelection, cartSelection);\n\n // User has valid selection that differs from cart\n if (userSelection && isUserSelectionAvailable && !haveSameSelection) {\n updateCartSelection(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, enabledOptions)\n ) {\n updateSelection(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, enabledOptions))\n ) {\n const newSelection = enabledOptions[0];\n updateSelection(newSelection);\n updateCartSelection(newSelection);\n }\n },\n [isEnabled, updateSelection, updateCartSelection]\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 useEffect(() => {\n notifyValues({ selectedPaymentMethod: selection });\n }, [selection]);\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 if (!selection) return;\n\n const slot = getSlot(selection);\n if (!slot) return;\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 }, [getSlot, selection, setAdditionalData]);\n\n return (\n <PaymentMethodsComponent\n UIComponentType={UIComponentType}\n busy={isBusy}\n error={error}\n initialized={isInitialized}\n options={withIcons(options)}\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","debouncedFn","args","HandlerCode","HANDLERS_CONFIG","PaymentOnAccount","PurchaseOrder","debouncedHandlers","handleRefNumberChange","isRequired","key","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","getSlot","useCallback","hasAutoSyncEnabled","isEnabled","withIcons","setAdditionalData","additionalData","prev","handleDismissError","updateSelection","updateCartSelection","fallback","isVirtualCart","hasShippingAddress","handleSelectionChange","prevSelection","getValue","handleCheckoutData","data","enabledOptions","cartSelection","hasCartSelection","userSelection","isUserSelectionAvailable","haveSameSelection","newSelection","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","events","onCheckoutUpdated","notifyValues","titleContent","Slot","slot","state","domElement"],"mappings":"ypDACA,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,CAAY,UAAW,GAAM,KAAK,QAAS,CAAA,CAAA,EAC9C,ECmCEC,GAAuD,CAAC,CAC5D,gBAAAC,EAAkB,eAClB,KAAA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ACT,eAAgB0B,GAChB,kBAAmBM,EAAA,CACrB,CAEJ","x_google_ignoreList":[0,3]}
@@ -12,7 +12,7 @@ export interface HandlePlaceOrderContext {
12
12
  export interface PlaceOrderProps extends HTMLAttributes<HTMLDivElement> {
13
13
  disabled?: boolean;
14
14
  active?: boolean;
15
- handleValidation?: () => boolean;
15
+ handleValidation?: () => boolean | Promise<boolean>;
16
16
  handlePlaceOrder: (ctx: HandlePlaceOrderContext) => Promise<void>;
17
17
  slots?: {
18
18
  Content?: SlotProps<ContentSlotContext>;
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as R,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{W as U}from"../chunks/ConditionalWrapper.js";/* empty css */import{Skeleton as W,SkeletonRow as E,Button as _}from"@dropins/tools/components.js";import{classes as q,Slot as B}from"@dropins/tools/lib.js";import{h as j,s as y,i as v}from"../chunks/fetch-graphql.js";import{c as w,E as P}from"../chunks/classifiers.js";import{events as u}from"@dropins/tools/event-bus.js";import{a as K}from"../chunks/events2.js";import{g}from"../chunks/values.js";import{useState as S,useCallback as m,useEffect as f}from"@dropins/tools/preact-hooks.js";import{useText as M}from"@dropins/tools/i18n.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";function Q(n){const r=w.find(o=>o.matches(n));return r?r.code:P.UNKNOWN_ERROR}const T=()=>R(W,{"data-testid":"place-order-skeleton",children:[s(E,{size:"small",variant:"empty"}),s(E,{size:"small"})]}),A=({children:n,className:r,disabled:o=!1,onClick:a})=>s("div",{className:q(["checkout-place-order",r]),children:s(_,{className:"checkout-place-order__button","data-testid":"place-order-button",disabled:o,size:"medium",type:"button",variant:"primary",onClick:a,children:n},"placeOrder")}),H=U(A,T),se=({disabled:n=!1,active:r=!0,handleValidation:o,handlePlaceOrder:a,slots:d,...b})=>{var O;const[x,p]=S(!1),[z,h]=S(!1),I=j.value,l=M({CheckoutUnexpectedError:"Checkout.ServerError.unexpected",placeOrderButton:"Checkout.PlaceOrder.button"}),k=m(e=>{const t=Q(e),i=t===P.UNKNOWN_ERROR?l.CheckoutUnexpectedError:e.message;u.emit("checkout/error",{message:i,code:t})},[l]),N=m(async()=>{var e;try{if(o&&!o())return;await a({cartId:y.cartId,quoteId:y.quoteId,code:((e=g("selectedPaymentMethod"))==null?void 0:e.code)??""})}catch(t){k(t)}},[o,a,k]),c=m(e=>{(!e||"isEmpty"in e&&e.isEmpty)&&h(!1)},[]);return f(()=>{if(r===!1)return;const e=u.on("cart/initialized",t=>{const i=(t==null?void 0:t.items)||[];h(i.some(C=>C.outOfStock||C.insufficientQuantity))},{eager:!0});return()=>{e==null||e.off()}},[r]),f(()=>{if(!r)return;const e=K();if(e){p(!0),c(e);return}const t=u.on("checkout/initialized",i=>{p(!0),c(i)},{eager:!0});return()=>{t==null||t.off()}},[r,c]),f(()=>{if(!r)return;const e=u.on("checkout/updated",t=>{c(t)},{eager:!1});return()=>{e==null||e.off()}},[r,c]),s(H,{...b,disabled:n||z||I||v.value,initialized:x,visible:r,onClick:N,children:s(B,{context:{code:((O=g("selectedPaymentMethod"))==null?void 0:O.code)??""},name:"Content",slot:d==null?void 0:d.Content,children:l.placeOrderButton})})};export{se as PlaceOrder,se as default};
3
+ import{jsxs as R,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{W as U}from"../chunks/ConditionalWrapper.js";/* empty css */import{Skeleton as W,SkeletonRow as E,Button as _}from"@dropins/tools/components.js";import{classes as q,Slot as w}from"@dropins/tools/lib.js";import{h as B,s as y,i as j}from"../chunks/fetch-graphql.js";import{c as v,E as P}from"../chunks/classifiers.js";import{events as u}from"@dropins/tools/event-bus.js";import{a as K}from"../chunks/events2.js";import{g}from"../chunks/values.js";import{useState as S,useCallback as m,useEffect as f}from"@dropins/tools/preact-hooks.js";import{useText as M}from"@dropins/tools/i18n.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";function Q(n){const r=v.find(o=>o.matches(n));return r?r.code:P.UNKNOWN_ERROR}const T=()=>R(W,{"data-testid":"place-order-skeleton",children:[s(E,{size:"small",variant:"empty"}),s(E,{size:"small"})]}),A=({children:n,className:r,disabled:o=!1,onClick:a})=>s("div",{className:q(["checkout-place-order",r]),children:s(_,{className:"checkout-place-order__button","data-testid":"place-order-button",disabled:o,size:"medium",type:"button",variant:"primary",onClick:a,children:n},"placeOrder")}),H=U(A,T),se=({disabled:n=!1,active:r=!0,handleValidation:o,handlePlaceOrder:a,slots:d,...b})=>{var O;const[x,p]=S(!1),[z,h]=S(!1),I=B.value,l=M({CheckoutUnexpectedError:"Checkout.ServerError.unexpected",placeOrderButton:"Checkout.PlaceOrder.button"}),k=m(e=>{const t=Q(e),i=t===P.UNKNOWN_ERROR?l.CheckoutUnexpectedError:e.message;u.emit("checkout/error",{message:i,code:t})},[l]),N=m(async()=>{var e;try{if(o&&!await o())return;await a({cartId:y.cartId,quoteId:y.quoteId,code:((e=g("selectedPaymentMethod"))==null?void 0:e.code)??""})}catch(t){k(t)}},[o,a,k]),c=m(e=>{(!e||"isEmpty"in e&&e.isEmpty)&&h(!1)},[]);return f(()=>{if(r===!1)return;const e=u.on("cart/initialized",t=>{const i=(t==null?void 0:t.items)||[];h(i.some(C=>C.outOfStock||C.insufficientQuantity))},{eager:!0});return()=>{e==null||e.off()}},[r]),f(()=>{if(!r)return;const e=K();if(e){p(!0),c(e);return}const t=u.on("checkout/initialized",i=>{p(!0),c(i)},{eager:!0});return()=>{t==null||t.off()}},[r,c]),f(()=>{if(!r)return;const e=u.on("checkout/updated",t=>{c(t)},{eager:!1});return()=>{e==null||e.off()}},[r,c]),s(H,{...b,disabled:n||z||I||j.value,initialized:x,visible:r,onClick:N,children:s(w,{context:{code:((O=g("selectedPaymentMethod"))==null?void 0:O.code)??""},name:"Content",slot:d==null?void 0:d.Content,children:l.placeOrderButton})})};export{se as PlaceOrder,se as default};
4
4
  //# sourceMappingURL=PlaceOrder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlaceOrder.js","sources":["/@dropins/storefront-checkout/src/lib/errors/mapErrorToCode.ts","/@dropins/storefront-checkout/src/components/PlaceOrder/PlaceOrderSkeleton.tsx","/@dropins/storefront-checkout/src/components/PlaceOrder/PlaceOrder.tsx","/@dropins/storefront-checkout/src/containers/PlaceOrder/PlaceOrder.tsx"],"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 classifiers,\n ErrorCode,\n ErrorCodes,\n} from '@/checkout/lib/errors/classifiers';\n\nexport function mapErrorToCode(error: unknown): ErrorCode {\n const matchingClassifier = classifiers.find((classifier) =>\n classifier.matches(error)\n );\n\n if (matchingClassifier) {\n return matchingClassifier.code;\n }\n\n return ErrorCodes.UNKNOWN_ERROR;\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 PlaceOrderSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"place-order-skeleton\">\n <SkeletonRow size=\"small\" variant=\"empty\" />\n <SkeletonRow size=\"small\" />\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/index';\nimport '@/checkout/components/PlaceOrder/PlaceOrder.css';\nimport { PlaceOrderSkeleton } from '@/checkout/components/PlaceOrder/PlaceOrderSkeleton';\nimport { Button } from '@adobe-commerce/elsie/components';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface PlaceOrderProps extends HTMLAttributes<HTMLDivElement> {\n disabled?: boolean;\n onClick: (event: Event) => Promise<void>;\n}\n\nconst PlaceOrderComponent: FunctionComponent<PlaceOrderProps> = ({\n children,\n className,\n disabled = false,\n onClick,\n}) => {\n return (\n <div className={classes(['checkout-place-order', className])}>\n <Button\n key=\"placeOrder\"\n className=\"checkout-place-order__button\"\n data-testid=\"place-order-button\"\n disabled={disabled}\n size=\"medium\"\n type=\"button\"\n variant=\"primary\"\n onClick={onClick}\n >\n {children}\n </Button>\n </div>\n );\n};\n\nexport const PlaceOrder = WithConditionals(\n PlaceOrderComponent,\n PlaceOrderSkeleton\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 { PlaceOrder as PlaceOrderComponent } from '@/checkout/components/PlaceOrder/PlaceOrder';\nimport { Cart, NegotiableQuote } from '@/checkout/data/models';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingUpdates,\n state,\n} from '@/checkout/lib';\nimport { isSetAddressRequestPending } from '@/checkout/store/ui';\nimport { ErrorCodes, mapErrorToCode } from '@/checkout/lib/errors';\nimport { Item as ItemModel } from '@/checkout/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\n\nexport interface ContentSlotContext {\n code: string;\n}\n\nexport interface HandlePlaceOrderContext {\n code: string;\n cartId?: string | null;\n quoteId?: string | null;\n}\n\nexport interface PlaceOrderProps extends HTMLAttributes<HTMLDivElement> {\n disabled?: boolean;\n active?: boolean;\n handleValidation?: () => boolean;\n handlePlaceOrder: (ctx: HandlePlaceOrderContext) => Promise<void>;\n slots?: {\n Content?: SlotProps<ContentSlotContext>;\n };\n}\n\nexport const PlaceOrder: Container<PlaceOrderProps> = ({\n disabled: disabledViaProp = false,\n active = true,\n handleValidation,\n handlePlaceOrder,\n slots,\n ...props\n}) => {\n const [isInitialized, setIsInitialized] = useState(false);\n const [hasOutOfStockItems, setHasOutOfStockItems] = useState(false);\n\n const hasQueuedUpdates = hasPendingUpdates.value;\n\n const translations = useText({\n CheckoutUnexpectedError: 'Checkout.ServerError.unexpected',\n placeOrderButton: 'Checkout.PlaceOrder.button',\n });\n\n const handlePlaceOrderError = useCallback(\n (error: any) => {\n const code = mapErrorToCode(error);\n\n const message =\n code === ErrorCodes.UNKNOWN_ERROR\n ? translations.CheckoutUnexpectedError\n : error.message;\n\n events.emit('checkout/error', { message, code });\n },\n [translations]\n );\n\n const handleClick = useCallback(async () => {\n try {\n if (handleValidation && !handleValidation()) return;\n\n await handlePlaceOrder({\n cartId: state.cartId,\n quoteId: state.quoteId,\n code: getValue('selectedPaymentMethod')?.code ?? '',\n });\n } catch (error: any) {\n handlePlaceOrderError(error);\n }\n }, [handleValidation, handlePlaceOrder, handlePlaceOrderError]);\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const isEmptyCart = !data || ('isEmpty' in data && data.isEmpty);\n\n if (isEmptyCart) {\n setHasOutOfStockItems(false);\n }\n },\n []\n );\n\n useEffect(() => {\n if (active === false) return;\n\n const onCartData = events.on(\n 'cart/initialized',\n (data) => {\n const items = (data?.items || []) as ItemModel[];\n setHasOutOfStockItems(\n items.some((item) => item.outOfStock || item.insufficientQuantity)\n );\n },\n { eager: true }\n );\n\n return () => {\n onCartData?.off();\n };\n }, [active]);\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n setIsInitialized(true);\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n (data) => {\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 (data) => {\n handleCheckoutData(data);\n },\n { eager: false }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n return (\n <PlaceOrderComponent\n {...props}\n disabled={\n disabledViaProp ||\n hasOutOfStockItems ||\n hasQueuedUpdates ||\n isSetAddressRequestPending.value\n }\n initialized={isInitialized}\n visible={active}\n onClick={handleClick}\n >\n <Slot\n context={{ code: getValue('selectedPaymentMethod')?.code ?? '' }}\n name=\"Content\"\n slot={slots?.Content}\n >\n {translations.placeOrderButton}\n </Slot>\n </PlaceOrderComponent>\n );\n};\n"],"names":["mapErrorToCode","error","matchingClassifier","classifiers","classifier","ErrorCodes","PlaceOrderSkeleton","jsxs","Skeleton","jsx","SkeletonRow","PlaceOrderComponent","children","className","disabled","onClick","classes","Button","PlaceOrder","WithConditionals","disabledViaProp","active","handleValidation","handlePlaceOrder","slots","props","isInitialized","setIsInitialized","useState","hasOutOfStockItems","setHasOutOfStockItems","hasQueuedUpdates","hasPendingUpdates","translations","useText","handlePlaceOrderError","useCallback","code","message","events","handleClick","state","_a","getValue","handleCheckoutData","data","useEffect","onCartData","items","item","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","onCheckoutUpdated","isSetAddressRequestPending","Slot"],"mappings":"+uBAuBO,SAASA,EAAeC,EAA2B,CACxD,MAAMC,EAAqBC,EAAY,KAAMC,GAC3CA,EAAW,QAAQH,CAAK,CAC1B,EAEA,OAAIC,EACKA,EAAmB,KAGrBG,EAAW,aACpB,CCbO,MAAMC,EAAwC,IAEjDC,EAACC,EAAS,CAAA,cAAY,uBACpB,SAAA,CAAAC,EAACC,EAAY,CAAA,KAAK,QAAQ,QAAQ,QAAQ,EAC1CD,EAACC,EAAY,CAAA,KAAK,OAAQ,CAAA,CAAA,EAC5B,ECKEC,EAA0D,CAAC,CAC/D,SAAAC,EACA,UAAAC,EACA,SAAAC,EAAW,GACX,QAAAC,CACF,IAEIN,EAAC,OAAI,UAAWO,EAAQ,CAAC,uBAAwBH,CAAS,CAAC,EACzD,SAAAJ,EAACQ,EAAA,CAEC,UAAU,+BACV,cAAY,qBACZ,SAAAH,EACA,KAAK,SACL,KAAK,SACL,QAAQ,UACR,QAAAC,EAEC,SAAAH,CAAA,EATG,YAAA,EAWR,EAISM,EAAaC,EACxBR,EACAL,CACF,ECHaY,GAAyC,CAAC,CACrD,SAAUE,EAAkB,GAC5B,OAAAC,EAAS,GACT,iBAAAC,EACA,iBAAAC,EACA,MAAAC,EACA,GAAGC,CACL,IAAM,OACJ,KAAM,CAACC,EAAeC,CAAgB,EAAIC,EAAS,EAAK,EAClD,CAACC,EAAoBC,CAAqB,EAAIF,EAAS,EAAK,EAE5DG,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GAAS,CACRlB,EAAiB,EAAI,EACrBiB,EAAmBC,CAAI,CACzB,EACA,CAAE,MAAO,EAAK,CAChB,EAEA,MAAO,IAAM,CACXO,GAAA,MAAAA,EAAgB,KAClB,CAAA,EACC,CAAC/B,EAAQuB,CAAkB,CAAC,EAE/BE,EAAU,IAAM,CACd,GAAI,CAACzB,EAAQ,OAEb,MAAMgC,EAAoBd,EAAO,GAC/B,mBACCM,GAAS,CACRD,EAAmBC,CAAI,CACzB,EACA,CAAE,MAAO,EAAM,CACjB,EAEA,MAAO,IAAM,CACXQ,GAAA,MAAAA,EAAmB,KACrB,CAAA,EACC,CAAChC,EAAQuB,CAAkB,CAAC,EAG7BnC,EAACE,EAAA,CACE,GAAGc,EACJ,SACEL,GACAS,GACAE,GACAuB,EAA2B,MAE7B,YAAa5B,EACb,QAASL,EACT,QAASmB,EAET,SAAA/B,EAAC8C,EAAA,CACC,QAAS,CAAE,OAAMb,EAAAC,EAAS,uBAAuB,IAAhC,YAAAD,EAAmC,OAAQ,EAAG,EAC/D,KAAK,UACL,KAAMlB,GAAA,YAAAA,EAAO,QAEZ,SAAaS,EAAA,gBAAA,CAAA,CAChB,CACF,CAEJ"}
1
+ {"version":3,"file":"PlaceOrder.js","sources":["/@dropins/storefront-checkout/src/lib/errors/mapErrorToCode.ts","/@dropins/storefront-checkout/src/components/PlaceOrder/PlaceOrderSkeleton.tsx","/@dropins/storefront-checkout/src/components/PlaceOrder/PlaceOrder.tsx","/@dropins/storefront-checkout/src/containers/PlaceOrder/PlaceOrder.tsx"],"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 classifiers,\n ErrorCode,\n ErrorCodes,\n} from '@/checkout/lib/errors/classifiers';\n\nexport function mapErrorToCode(error: unknown): ErrorCode {\n const matchingClassifier = classifiers.find((classifier) =>\n classifier.matches(error)\n );\n\n if (matchingClassifier) {\n return matchingClassifier.code;\n }\n\n return ErrorCodes.UNKNOWN_ERROR;\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 PlaceOrderSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"place-order-skeleton\">\n <SkeletonRow size=\"small\" variant=\"empty\" />\n <SkeletonRow size=\"small\" />\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/index';\nimport '@/checkout/components/PlaceOrder/PlaceOrder.css';\nimport { PlaceOrderSkeleton } from '@/checkout/components/PlaceOrder/PlaceOrderSkeleton';\nimport { Button } from '@adobe-commerce/elsie/components';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface PlaceOrderProps extends HTMLAttributes<HTMLDivElement> {\n disabled?: boolean;\n onClick: (event: Event) => Promise<void>;\n}\n\nconst PlaceOrderComponent: FunctionComponent<PlaceOrderProps> = ({\n children,\n className,\n disabled = false,\n onClick,\n}) => {\n return (\n <div className={classes(['checkout-place-order', className])}>\n <Button\n key=\"placeOrder\"\n className=\"checkout-place-order__button\"\n data-testid=\"place-order-button\"\n disabled={disabled}\n size=\"medium\"\n type=\"button\"\n variant=\"primary\"\n onClick={onClick}\n >\n {children}\n </Button>\n </div>\n );\n};\n\nexport const PlaceOrder = WithConditionals(\n PlaceOrderComponent,\n PlaceOrderSkeleton\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 { PlaceOrder as PlaceOrderComponent } from '@/checkout/components/PlaceOrder/PlaceOrder';\nimport { Cart, NegotiableQuote } from '@/checkout/data/models';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingUpdates,\n state,\n} from '@/checkout/lib';\nimport { isSetAddressRequestPending } from '@/checkout/store/ui';\nimport { ErrorCodes, mapErrorToCode } from '@/checkout/lib/errors';\nimport { Item as ItemModel } from '@/checkout/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\n\nexport interface ContentSlotContext {\n code: string;\n}\n\nexport interface HandlePlaceOrderContext {\n code: string;\n cartId?: string | null;\n quoteId?: string | null;\n}\n\nexport interface PlaceOrderProps extends HTMLAttributes<HTMLDivElement> {\n disabled?: boolean;\n active?: boolean;\n handleValidation?: () => boolean | Promise<boolean>;\n handlePlaceOrder: (ctx: HandlePlaceOrderContext) => Promise<void>;\n slots?: {\n Content?: SlotProps<ContentSlotContext>;\n };\n}\n\nexport const PlaceOrder: Container<PlaceOrderProps> = ({\n disabled: disabledViaProp = false,\n active = true,\n handleValidation,\n handlePlaceOrder,\n slots,\n ...props\n}) => {\n const [isInitialized, setIsInitialized] = useState(false);\n const [hasOutOfStockItems, setHasOutOfStockItems] = useState(false);\n\n const hasQueuedUpdates = hasPendingUpdates.value;\n\n const translations = useText({\n CheckoutUnexpectedError: 'Checkout.ServerError.unexpected',\n placeOrderButton: 'Checkout.PlaceOrder.button',\n });\n\n const handlePlaceOrderError = useCallback(\n (error: any) => {\n const code = mapErrorToCode(error);\n\n const message =\n code === ErrorCodes.UNKNOWN_ERROR\n ? translations.CheckoutUnexpectedError\n : error.message;\n\n events.emit('checkout/error', { message, code });\n },\n [translations]\n );\n\n const handleClick = useCallback(async () => {\n try {\n if (handleValidation && !(await handleValidation())) return;\n\n await handlePlaceOrder({\n cartId: state.cartId,\n quoteId: state.quoteId,\n code: getValue('selectedPaymentMethod')?.code ?? '',\n });\n } catch (error: any) {\n handlePlaceOrderError(error);\n }\n }, [handleValidation, handlePlaceOrder, handlePlaceOrderError]);\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const isEmptyCart = !data || ('isEmpty' in data && data.isEmpty);\n\n if (isEmptyCart) {\n setHasOutOfStockItems(false);\n }\n },\n []\n );\n\n useEffect(() => {\n if (active === false) return;\n\n const onCartData = events.on(\n 'cart/initialized',\n (data) => {\n const items = (data?.items || []) as ItemModel[];\n setHasOutOfStockItems(\n items.some((item) => item.outOfStock || item.insufficientQuantity)\n );\n },\n { eager: true }\n );\n\n return () => {\n onCartData?.off();\n };\n }, [active]);\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n setIsInitialized(true);\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n (data) => {\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 (data) => {\n handleCheckoutData(data);\n },\n { eager: false }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n return (\n <PlaceOrderComponent\n {...props}\n disabled={\n disabledViaProp ||\n hasOutOfStockItems ||\n hasQueuedUpdates ||\n isSetAddressRequestPending.value\n }\n initialized={isInitialized}\n visible={active}\n onClick={handleClick}\n >\n <Slot\n context={{ code: getValue('selectedPaymentMethod')?.code ?? '' }}\n name=\"Content\"\n slot={slots?.Content}\n >\n {translations.placeOrderButton}\n </Slot>\n </PlaceOrderComponent>\n );\n};\n"],"names":["mapErrorToCode","error","matchingClassifier","classifiers","classifier","ErrorCodes","PlaceOrderSkeleton","jsxs","Skeleton","jsx","SkeletonRow","PlaceOrderComponent","children","className","disabled","onClick","classes","Button","PlaceOrder","WithConditionals","disabledViaProp","active","handleValidation","handlePlaceOrder","slots","props","isInitialized","setIsInitialized","useState","hasOutOfStockItems","setHasOutOfStockItems","hasQueuedUpdates","hasPendingUpdates","translations","useText","handlePlaceOrderError","useCallback","code","message","events","handleClick","state","_a","getValue","handleCheckoutData","data","useEffect","onCartData","items","item","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","onCheckoutUpdated","isSetAddressRequestPending","Slot"],"mappings":"+uBAuBO,SAASA,EAAeC,EAA2B,CACxD,MAAMC,EAAqBC,EAAY,KAAMC,GAC3CA,EAAW,QAAQH,CAAK,CAC1B,EAEA,OAAIC,EACKA,EAAmB,K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AuB,EAA2B,MAE7B,YAAa5B,EACb,QAASL,EACT,QAASmB,EAET,SAAA/B,EAAC8C,EAAA,CACC,QAAS,CAAE,OAAMb,EAAAC,EAAS,uBAAuB,IAAhC,YAAAD,EAAmC,OAAQ,EAAG,EAC/D,KAAK,UACL,KAAMlB,GAAA,YAAAA,EAAO,QAEZ,SAAaS,EAAA,gBAAA,CAAA,CAChB,CACF,CAEJ"}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as A,jsx as r,Fragment as K}from"@dropins/tools/preact-jsx-runtime.js";import{h as pe,n as de,o as X}from"../chunks/fetch-graphql.js";import{classes as D,VComponent as he,Slot as me}from"@dropins/tools/lib.js";import{t as fe}from"../chunks/transform-shipping-estimate.js";import{h as I,a as ge}from"../chunks/events2.js";import{n as ke,g as N}from"../chunks/values.js";import{events as B}from"@dropins/tools/event-bus.js";import{c as Y}from"../chunks/synchronizeCheckout.js";import{s as ve}from"../chunks/setShippingMethods.js";import{W as Se}from"../chunks/ConditionalWrapper.js";/* empty css */import{Skeleton as Ee,SkeletonRow as T,IllustratedMessage as Ce,Icon as Le,InLineAlert as Me,RadioButton as ye,Price as ee,ToggleButton as _e}from"@dropins/tools/components.js";import{s as We}from"../chunks/dom.js";import{useRef as ne,useEffect as R,useState as V,useCallback as p,useMemo as te}from"@dropins/tools/preact-hooks.js";import*as a from"@dropins/tools/preact-compat.js";import{useText as re}from"@dropins/tools/i18n.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/transform-shipping-methods.js";import"../chunks/classifiers.js";import"../chunks/guards.js";const je=i=>a.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.47266 4.90002H15.1851V10.9645H21.2495L23 12.715V17.6124H20.073",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76151 16.7898C9.76151 18.0525 8.72845 19.076 7.46582 19.076C6.20318 19.076 5.17969 18.0429 5.17969 16.7803C5.17969 15.5176 6.20318 14.4941 7.46582 14.4941C8.72845 14.4941 9.75195 15.5176 9.76151 16.7803C9.76151 16.7803 9.76151 16.7803 9.76151 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8726 16.7898C19.8726 18.062 18.8491 19.0855 17.5769 19.0855C16.3047 19.0855 15.2812 18.062 15.2812 16.7898C15.2812 15.5176 16.3047 14.4941 17.5769 14.4941C18.8491 14.4941 19.8726 15.5176 19.8726 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),Be=()=>A(Ee,{"data-testid":"shipping-methods-skeleton",children:[r(T,{size:"small",variant:"heading"}),r(T,{size:"small",variant:"empty"}),r(T,{fullWidth:!0,size:"medium"}),r(T,{fullWidth:!0,size:"medium"})]}),Oe=({className:i,busy:n=!1,onSelectionChange:g=()=>{},options:v,selection:d,title:l,UIComponentType:u="RadioButton",error:h=null,onDismissError:b=()=>{},...U})=>{const S=re({EmptyState:"Checkout.ShippingMethods.emptyState"}),E=h!==null,C=ne(null);R(()=>{E&&C.current&&We(C.current)},[E]);const L=(o,x)=>{const M={busy:n,className:"checkout-shipping-methods__method",key:o.value,name:"shipping-method",value:o.value,onChange:()=>g(o)};return x==="RadioButton"?r(ye,{...M,checked:(d==null?void 0:d.value)===o.value,"data-testid":"shipping-method-radioButton",description:o.title,disabled:n,id:o.value,label:A(K,{children:[r(ee,{amount:o.amount.value,currency:o.amount.currency})," ",r("span",{children:o.carrier.title})]})}):r(_e,{...M,"data-testid":"shipping-method-toggleButton",label:A(K,{children:[r("span",{children:o.carrier.title}),r(ee,{amount:o.amount.value,currency:o.amount.currency})]}),selected:(d==null?void 0:d.value)===o.value})};return A("div",{...U,className:D(["checkout-shipping-methods",i]),"data-testid":"checkout-shipping-methods",children:[l&&r(he,{className:"checkout-shipping-methods__title",node:l}),r("div",{className:D(["checkout-shipping-methods__content"]),children:r("div",{className:D(["checkout-shipping-methods__options",["checkout-shipping-methods__options--busy",n],["checkout-shipping-methods__options--toggleButton",u==="ToggleButton"]]),"data-testid":"checkout-shipping-methods-options",children:v.length===0?r(Ce,{"data-testid":"checkout-shipping-methods-empty",icon:r(Le,{source:je}),message:r("p",{children:S.EmptyState})}):v.map(o=>L(o,u))})}),E&&r("div",{ref:C,className:"checkout-shipping-methods__error","data-testid":"checkout-shipping-methods-alert",children:r(Me,{heading:h,type:"error",variant:"primary",onDismiss:b})})]})},we=Se(Oe,Be);function P(i,n){return i?n.some(g=>Q(g,i)):!1}function Q(i,n){return!i||!n||i.amount.value!==n.amount.value?!1:i.code===n.code&&i.carrier.code===n.carrier.code}function He(i){const n=B.lastPayload("shipping/estimate");n&&B.emit("shipping/estimate",{...n,shippingMethod:fe(i)})}const Ye=({UIComponentType:i="RadioButton",active:n=!0,autoSync:g=!0,displayTitle:v=!0,initialData:d,slots:l,onCartSyncError:u,onSelectionChange:h,...b})=>{const[U,S]=V(null),[E,C]=V(!1),[L,o]=V(),[x,M]=V(null),O=ne(null),oe=pe.value,ie=de.value,{cartSyncError:Z,defaultTitle:q}=re({cartSyncError:"Checkout.ShippingMethods.cartSyncError",defaultTitle:"Checkout.ShippingMethods.title"}),w=p(e=>{if(!e||e.length===0)return[];const{shipping:t}=Y.getConfig();return t!=null&&t.filterOptions?e.filter(t.filterOptions):e},[]),F=p(e=>{if(e.length===0)return null;const{defaults:t}=Y.getConfig();return t.selectedShippingMethod(e)},[]),se=te(()=>w(L),[L,w]),ce=p(()=>{S(null)},[]),c=p(e=>{S(null),M(t=>Q(t,e)?t:(ke({selectedShippingMethod:e}),e))},[]),y=p(async(e,t)=>{if(!g||!I())return;const s={carrierCode:e.carrier.code,methodCode:e.code};ve([s]).catch(m=>{c(t??null),u==null||u({method:e,error:m}),u||S(Z)})},[g,c,u,Z]),ae=p(async e=>{const t=N("selectedShippingMethod");c(e),h==null||h(e),I()||He(e),await y(e,t)},[h,c,y]),_=p(e=>{var J;const t=!e||e.isEmpty,s=!!(e!=null&&e.isVirtual);if(t||s){C(s),c(null),o([]);return}const m=(J=e.shippingAddresses)==null?void 0:J[0];if(!m)return;const W=m.availableShippingMethods??[];X()&&!O.current&&(O.current=W);const G=X()&&O.current?O.current:W;o(G);const j=w(G);if(j.length===0){c(null);return}const f=m.selectedShippingMethod??null,k=N("selectedShippingMethod"),z=P(k,j),ue=Q(k,f);if(k&&z&&!ue){y(k,f);return}if((!k||!z)&&f&&P(f,j)){c(f);return}if((!k||!z)&&(!f||!P(f,j))){const H=F(j);c(H),H&&y(H)}},[w,F,c,y]),$=p(e=>{if(e===void 0)return;const{shippingMethod:t,availableShippingMethods:s}=e,m=(s==null?void 0:s.find(W=>W.code===(t==null?void 0:t.methodCode)&&W.carrier.code===(t==null?void 0:t.carrierCode)))??null;o(s),c(m)},[c]);R(()=>{if(!n)return;const e=ge();if(e){const s=N("selectedShippingMethod");s&&M(s),_(e);return}const t=B.on("checkout/initialized",_,{eager:!0});return()=>{t==null||t.off()}},[n,_]),R(()=>{if(!n)return;const e=B.on("checkout/updated",_,{eager:!1});return()=>{e==null||e.off()}},[n,_]),R(()=>{if(!n||I())return;const e=B.on("shipping/estimate",$,{eager:!0});return()=>{e==null||e.off()}},[n,$]);const le=te(()=>{if(v)return r(me,{name:"checkout-shipping-methods-title",slot:l==null?void 0:l.Title,children:r("h3",{children:q})})},[v,l==null?void 0:l.Title,q]);return r(we,{...b,UIComponentType:i,busy:oe||ie,error:U,initialized:L!==void 0,options:se,selection:x,title:le,visible:n&&!E,onDismissError:ce,onSelectionChange:ae})};export{Ye as ShippingMethods,Ye as default,He as emitShippingEstimateEvent};
3
+ import{jsxs as j,jsx as n,Fragment as X}from"@dropins/tools/preact-jsx-runtime.js";import{h as pe,n as de,o as Y}from"../chunks/fetch-graphql.js";import{classes as D,VComponent as he,Slot as me}from"@dropins/tools/lib.js";import{t as fe}from"../chunks/transform-shipping-estimate.js";import{h as I,a as ge}from"../chunks/events2.js";import{n as ke,g as P}from"../chunks/values.js";import{events as B}from"@dropins/tools/event-bus.js";import{c as ee}from"../chunks/synchronizeCheckout.js";import{s as ve}from"../chunks/setShippingMethods.js";import{W as Se}from"../chunks/ConditionalWrapper.js";/* empty css */import{Skeleton as Ee,SkeletonRow as H,IllustratedMessage as Ce,Icon as _e,InLineAlert as Le,RadioButton as Me,Price as T,ToggleButton as ye}from"@dropins/tools/components.js";import{s as Ae}from"../chunks/dom.js";import{useRef as re,useEffect as R,useState as V,useCallback as p,useMemo as te}from"@dropins/tools/preact-hooks.js";import*as a from"@dropins/tools/preact-compat.js";import{useText as ne}from"@dropins/tools/i18n.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/transform-shipping-methods.js";import"../chunks/classifiers.js";import"../chunks/guards.js";const We=o=>a.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o},a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.47266 4.90002H15.1851V10.9645H21.2495L23 12.715V17.6124H20.073",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76151 16.7898C9.76151 18.0525 8.72845 19.076 7.46582 19.076C6.20318 19.076 5.17969 18.0429 5.17969 16.7803C5.17969 15.5176 6.20318 14.4941 7.46582 14.4941C8.72845 14.4941 9.75195 15.5176 9.76151 16.7803C9.76151 16.7803 9.76151 16.7803 9.76151 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8726 16.7898C19.8726 18.062 18.8491 19.0855 17.5769 19.0855C16.3047 19.0855 15.2812 18.062 15.2812 16.7898C15.2812 15.5176 16.3047 14.4941 17.5769 14.4941C18.8491 14.4941 19.8726 15.5176 19.8726 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),je=()=>j(Ee,{"data-testid":"shipping-methods-skeleton",children:[n(H,{size:"small",variant:"heading"}),n(H,{size:"small",variant:"empty"}),n(H,{fullWidth:!0,size:"medium"}),n(H,{fullWidth:!0,size:"medium"})]}),Be=({className:o,busy:i=!1,onSelectionChange:g=()=>{},options:v,selection:d,title:l,UIComponentType:u="RadioButton",error:h=null,onDismissError:b=()=>{},...U})=>{const S=ne({EmptyState:"Checkout.ShippingMethods.emptyState"}),E=h!==null,C=re(null);R(()=>{E&&C.current&&Ae(C.current)},[E]);const _=(r,x)=>{const L={busy:i,className:"checkout-shipping-methods__method",key:r.value,name:"shipping-method",value:r.value,onChange:()=>g(r)};return x==="RadioButton"?n(Me,{...L,checked:(d==null?void 0:d.value)===r.value,"data-testid":"shipping-method-radioButton",description:r.title,disabled:i,id:r.value,label:j(X,{children:[r.originalAmount&&n(T,{amount:r.originalAmount.value,className:"checkout-shipping-methods__price--original",currency:r.originalAmount.currency,"data-testid":"shipping-method-original-price",variant:"strikethrough"}),n(T,{amount:r.amount.value,className:"checkout-shipping-methods__price",currency:r.amount.currency})," ",n("span",{children:r.carrier.title})]})}):n(ye,{...L,"data-testid":"shipping-method-toggleButton",label:j(X,{children:[n("span",{children:r.carrier.title}),j("div",{className:"checkout-shipping-methods__price-wrapper",children:[r.originalAmount&&n(T,{amount:r.originalAmount.value,className:"checkout-shipping-methods__price--original",currency:r.originalAmount.currency,"data-testid":"shipping-method-original-price",variant:"strikethrough"}),n(T,{amount:r.amount.value,className:"checkout-shipping-methods__price",currency:r.amount.currency})]})]}),selected:(d==null?void 0:d.value)===r.value})};return j("div",{...U,className:D(["checkout-shipping-methods",o]),"data-testid":"checkout-shipping-methods",children:[l&&n(he,{className:"checkout-shipping-methods__title",node:l}),n("div",{className:D(["checkout-shipping-methods__content"]),children:n("div",{className:D(["checkout-shipping-methods__options",["checkout-shipping-methods__options--busy",i],["checkout-shipping-methods__options--toggleButton",u==="ToggleButton"]]),"data-testid":"checkout-shipping-methods-options",children:v.length===0?n(Ce,{"data-testid":"checkout-shipping-methods-empty",icon:n(_e,{source:We}),message:n("p",{children:S.EmptyState})}):v.map(r=>_(r,u))})}),E&&n("div",{ref:C,className:"checkout-shipping-methods__error","data-testid":"checkout-shipping-methods-alert",children:n(Le,{heading:h,type:"error",variant:"primary",onDismiss:b})})]})},Ne=Se(Be,je);function Q(o,i){return o?i.some(g=>Z(g,o)):!1}function Z(o,i){return!o||!i||o.amount.value!==i.amount.value?!1:o.code===i.code&&o.carrier.code===i.carrier.code}function Oe(o){const i=B.lastPayload("shipping/estimate");i&&B.emit("shipping/estimate",{...i,shippingMethod:fe(o)})}const Ye=({UIComponentType:o="RadioButton",active:i=!0,autoSync:g=!0,displayTitle:v=!0,initialData:d,slots:l,onCartSyncError:u,onSelectionChange:h,...b})=>{const[U,S]=V(null),[E,C]=V(!1),[_,r]=V(),[x,L]=V(null),N=re(null),ie=pe.value,oe=de.value,{cartSyncError:q,defaultTitle:F}=ne({cartSyncError:"Checkout.ShippingMethods.cartSyncError",defaultTitle:"Checkout.ShippingMethods.title"}),O=p(e=>{if(!e||e.length===0)return[];const{shipping:t}=ee.getConfig();return t!=null&&t.filterOptions?e.filter(t.filterOptions):e},[]),$=p(e=>{if(e.length===0)return null;const{defaults:t}=ee.getConfig();return t.selectedShippingMethod(e)},[]),se=te(()=>O(_),[_,O]),ce=p(()=>{S(null)},[]),c=p(e=>{S(null),L(t=>Z(t,e)?t:(ke({selectedShippingMethod:e}),e))},[]),M=p(async(e,t)=>{if(!g||!I())return;const s={carrierCode:e.carrier.code,methodCode:e.code};ve([s]).catch(m=>{c(t??null),u==null||u({method:e,error:m}),u||S(q)})},[g,c,u,q]),ae=p(async e=>{const t=P("selectedShippingMethod");c(e),h==null||h(e),I()||Oe(e),await M(e,t)},[h,c,M]),y=p(e=>{var K;const t=!e||e.isEmpty,s=!!(e!=null&&e.isVirtual);if(t||s){C(s),c(null),r([]);return}const m=(K=e.shippingAddresses)==null?void 0:K[0];if(!m)return;const A=m.availableShippingMethods??[];Y()&&!N.current&&(N.current=A);const J=Y()&&N.current?N.current:A;r(J);const W=O(J);if(W.length===0){c(null);return}const f=m.selectedShippingMethod??null,k=P("selectedShippingMethod"),z=Q(k,W),ue=Z(k,f);if(k&&z&&!ue){M(k,f);return}if((!k||!z)&&f&&Q(f,W)){c(f);return}if((!k||!z)&&(!f||!Q(f,W))){const w=$(W);c(w),w&&M(w)}},[O,$,c,M]),G=p(e=>{if(e===void 0)return;const{shippingMethod:t,availableShippingMethods:s}=e,m=(s==null?void 0:s.find(A=>A.code===(t==null?void 0:t.methodCode)&&A.carrier.code===(t==null?void 0:t.carrierCode)))??null;r(s),c(m)},[c]);R(()=>{if(!i)return;const e=ge();if(e){const s=P("selectedShippingMethod");s&&L(s),y(e);return}const t=B.on("checkout/initialized",y,{eager:!0});return()=>{t==null||t.off()}},[i,y]),R(()=>{if(!i)return;const e=B.on("checkout/updated",y,{eager:!1});return()=>{e==null||e.off()}},[i,y]),R(()=>{if(!i||I())return;const e=B.on("shipping/estimate",G,{eager:!0});return()=>{e==null||e.off()}},[i,G]);const le=te(()=>{if(v)return n(me,{name:"checkout-shipping-methods-title",slot:l==null?void 0:l.Title,children:n("h3",{children:F})})},[v,l==null?void 0:l.Title,F]);return n(Ne,{...b,UIComponentType:o,busy:ie||oe,error:U,initialized:_!==void 0,options:se,selection:x,title:le,visible:i&&!E,onDismissError:ce,onSelectionChange:ae})};export{Ye as ShippingMethods,Ye as default,Oe as emitShippingEstimateEvent};
4
4
  //# sourceMappingURL=ShippingMethods.js.map
@@ -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';\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 &nbsp;\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 isQuoteCheckout,\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 {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} 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 const initialQuoteOptions = useRef<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\n // For quote checkouts, preserve initial shipping methods. After the first method is selected,\n // the backend only returns that selected method, preventing users from changing to other\n // options. We maintain all initial options to match Luma's behavior.\n if (isQuoteCheckout() && !initialQuoteOptions.current) {\n initialQuoteOptions.current = availableOptions;\n }\n\n const effectiveOptions =\n isQuoteCheckout() && initialQuoteOptions.current\n ? initialQuoteOptions.current\n : availableOptions;\n\n setOptions(effectiveOptions);\n const filteredOptions = filterOptions(effectiveOptions);\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","initialQuoteOptions","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","isQuoteCheckout","effectiveOptions","cartSelection","userSelection","isAvailable","haveSameSelection","newSelection","handleShippingEstimate","estimation","availableShippingMethods","selectedShippingMethod","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","onCheckoutUpdated","onShippingEstimate","titleContent","Slot"],"mappings":"qvCACA,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,EAAG,kNAAmN,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,2BAA4B,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAAE,EAAmBA,EAAM,cAAc,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C2B,GAAUmC,IAAsB,OAErC,MAAM4B,EAAqBjE,EAAO,GAChC,oBACAyD,EACA,CAAE,MAAO,EAAK,CAChB,EAEA,MAAO,IAAM,CACXQ,GAAA,MAAAA,EAAoB,KACtB,CAAA,EACC,CAAC/D,EAAQuD,CAAsB,CAAC,EAE7B,MAAAS,GAAerC,GAAQ,IAAM,CAC7B,GAACzB,EAGH,OAAA9C,EAAC6G,GAAK,CAAA,KAAK,kCAAkC,KAAM7D,GAAA,YAAAA,EAAO,MACxD,SAAAhD,EAAC,KAAI,CAAA,SAAA8D,CAAa,CAAA,EACpB,GAED,CAAChB,EAAcE,GAAA,YAAAA,EAAO,MAAOc,CAAY,CAAC,EAG3C,OAAA9D,EAACE,GAAA,CACE,GAAGP,EACJ,gBAAiBc,EACjB,KAAMgD,IAAoBE,GAC1B,MAAAjD,EACA,YAAaJ,IAAY,OACzB,QAASgE,GACT,UAAA/D,EACA,MAAOqG,GACP,QAAShE,GAAU,CAACQ,EACpB,eAAgBoB,GAChB,kBAAmBU,EAAA,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 {method.originalAmount && (\n <Price\n amount={method.originalAmount.value}\n className=\"checkout-shipping-methods__price--original\"\n currency={method.originalAmount.currency}\n data-testid=\"shipping-method-original-price\"\n variant=\"strikethrough\"\n />\n )}\n <Price\n amount={method.amount.value}\n className=\"checkout-shipping-methods__price\"\n currency={method.amount.currency}\n />\n &nbsp;\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 <div className=\"checkout-shipping-methods__price-wrapper\">\n {method.originalAmount && (\n <Price\n amount={method.originalAmount.value}\n className=\"checkout-shipping-methods__price--original\"\n currency={method.originalAmount.currency}\n data-testid=\"shipping-method-original-price\"\n variant=\"strikethrough\"\n />\n )}\n <Price\n amount={method.amount.value}\n className=\"checkout-shipping-methods__price\"\n currency={method.amount.currency}\n />\n </div>\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 isQuoteCheckout,\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 {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} 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 const initialQuoteOptions = useRef<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\n // For quote checkouts, preserve initial shipping methods. After the first method is selected,\n // the backend only returns that selected method, preventing users from changing to other\n // options. We maintain all initial options to match Luma's behavior.\n if (isQuoteCheckout() && !initialQuoteOptions.current) {\n initialQuoteOptions.current = availableOptions;\n }\n\n const effectiveOptions =\n isQuoteCheckout() && initialQuoteOptions.current\n ? initialQuoteOptions.current\n : availableOptions;\n\n setOptions(effectiveOptions);\n const filteredOptions = filterOptions(effectiveOptions);\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","initialQuoteOptions","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","isQuoteCheckout","effectiveOptions","cartSelection","userSelection","isAvailable","haveSameSelection","newSelection","handleShippingEstimate","estimation","availableShippingMethods","selectedShippingMethod","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","onCheckoutUpdated","onShippingEstimate","titleContent","Slot"],"mappings":"qvCACA,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,EAAG,kNAAmN,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,2BAA4B,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,qBAAsB,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,QAAS,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,2BAA4B,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAA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,MAAO,EAAM,CACjB,EAEA,MAAO,IAAM,CACXqB,GAAA,MAAAA,EAAmB,KACrB,CAAA,EACC,CAAC9D,EAAQyC,CAAkB,CAAC,EAE/BpE,EAAU,IAAM,CACV,GAAA,CAAC2B,GAAUmC,IAAsB,OAErC,MAAM4B,EAAqBjE,EAAO,GAChC,oBACAyD,EACA,CAAE,MAAO,EAAK,CAChB,EAEA,MAAO,IAAM,CACXQ,GAAA,MAAAA,EAAoB,KACtB,CAAA,EACC,CAAC/D,EAAQuD,CAAsB,CAAC,EAE7B,MAAAS,GAAerC,GAAQ,IAAM,CAC7B,GAACzB,EAGH,OAAA9C,EAAC6G,GAAK,CAAA,KAAK,kCAAkC,KAAM7D,GAAA,YAAAA,EAAO,MACxD,SAAAhD,EAAC,KAAI,CAAA,SAAA8D,CAAa,CAAA,EACpB,GAED,CAAChB,EAAcE,GAAA,YAAAA,EAAO,MAAOc,CAAY,CAAC,EAG3C,OAAA9D,EAACE,GAAA,CACE,GAAGP,EACJ,gBAAiBc,EACjB,KAAMgD,IAAoBE,GAC1B,MAAAjD,EACA,YAAaJ,IAAY,OACzB,QAASgE,GACT,UAAA/D,EACA,MAAOqG,GACP,QAAShE,GAAU,CAACQ,EACpB,eAAgBoB,GAChB,kBAAmBU,EAAA,CACrB,CAEJ","x_google_ignoreList":[0]}
@@ -12,6 +12,7 @@ export type ShippingMethod = {
12
12
  value: string;
13
13
  amountExclTax?: Money;
14
14
  amountInclTax?: Money;
15
+ originalAmount?: Money;
15
16
  };
16
17
  export {};
17
18
  //# sourceMappingURL=shipping-method.d.ts.map
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-checkout", "version": "3.0.1", "@dropins/tools": "1.6.0", "license": "SEE LICENSE IN LICENSE.md"}
1
+ {"name": "@dropins/storefront-checkout", "version": "3.1.0-beta1", "@dropins/tools": "1.7.0-beta3", "license": "SEE LICENSE IN LICENSE.md"}
package/render.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
3
  (function(n,o){try{if(typeof document<"u"){const t=document.createElement("style"),r=o.styleId;for(const e in o.attributes)t.setAttribute(e,o.attributes[e]);t.setAttribute("data-dropin",r),t.appendChild(document.createTextNode(n));const a=document.querySelector('style[data-dropin="sdk"]');if(a)a.after(t);else{const e=document.querySelector('link[rel="stylesheet"], style');e?e.before(t):document.head.append(t)}}}catch(t){console.error("dropin-styles (injectCodeFunction)",t)}})(`.checkout__banner{margin-bottom:var(--spacing-xbig)}
4
- .checkout-shipping-methods__title,.checkout-shipping-methods__title h3{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-shipping-methods__content{position:relative;display:block}.checkout-shipping-methods__method{margin-bottom:var(--spacing-medium);width:fit-content;cursor:pointer;font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-shipping-methods__method:last-child{margin-bottom:0}.dropin-radio-button__label .dropin-price{color:var(--color-neutral-800);font-weight:400}.checkout-shipping-methods__options--busy{opacity:.4;pointer-events:none}.checkout-shipping-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0}.checkout-shipping-methods__options--toggleButton{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium)}.checkout-shipping-methods__options--toggleButton .dropin-toggle-button__content{justify-content:start;display:grid;grid-template-columns:1fr min-content}.checkout-shipping-methods__options--toggleButton .checkout-shipping-methods__method{margin-bottom:0;width:auto}.checkout-shipping-methods__error{margin-top:var(--spacing-medium)}
4
+ .checkout-shipping-methods__title,.checkout-shipping-methods__title h3{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-shipping-methods__content{position:relative;display:block}.checkout-shipping-methods__method{margin-bottom:var(--spacing-medium);width:fit-content;cursor:pointer;font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-shipping-methods__method:last-child{margin-bottom:0}.dropin-radio-button__label .dropin-price{color:var(--color-neutral-800);font-weight:400}.checkout-shipping-methods__price--original{margin-right:var(--spacing-xxsmall)}.checkout-shipping-methods__price-wrapper{display:flex;gap:var(--spacing-xxsmall);align-items:center}.checkout-shipping-methods__options--busy{opacity:.4;pointer-events:none}.checkout-shipping-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0}.checkout-shipping-methods__options--toggleButton{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium)}.checkout-shipping-methods__options--toggleButton .dropin-toggle-button__content{justify-content:start;display:grid;grid-template-columns:1fr min-content}.checkout-shipping-methods__options--toggleButton .checkout-shipping-methods__method{margin-bottom:0;width:auto}.checkout-shipping-methods__error{margin-top:var(--spacing-medium)}
5
5
  .checkout-place-order{display:grid;padding-bottom:var(--spacing-big)}.checkout-place-order__button{align-self:flex-end;justify-self:flex-end}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-place-order{background-color:var(--color-neutral-200);padding:var(--spacing-medium) var(--spacing-medium) var(--spacing-big) var(--spacing-medium)}.checkout-place-order__button{align-self:center;justify-self:stretch}}
6
6
  .checkout-payment-on-account{margin-bottom:var(--spacing-medium)}.checkout-payment-on-account__form{width:100%}.checkout-payment-on-account__credit{display:flex;justify-content:space-between;align-items:center;padding:var(--spacing-small);margin-bottom:var(--spacing-medium);background-color:var(--color-neutral-100);border:1px solid var(--color-neutral-300);border-radius:4px;font-size:14px;line-height:1.4}.checkout-payment-on-account__credit-label{font-weight:500;color:var(--color-neutral-700)}.checkout-payment-on-account__credit-amount{font-weight:600;color:var(--color-success-600)}.checkout-payment-on-account__exceed-message{margin-top:var(--spacing-medium);margin-bottom:var(--spacing-medium)}.checkout-payment-on-account .dropin-field{margin-bottom:0}
7
7
  .checkout-bill-to-shipping-address label{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);gap:0}.checkout-bill-to-shipping-address__error{margin-top:var(--spacing-medium)}
@@ -1,6 +1,6 @@
1
1
  import { CurrencyEnum } from '../../../__generated__/types';
2
2
 
3
- export declare const availableShippingMethodsFixture: {
3
+ export declare const availableShippingMethodsFixture: ({
4
4
  amount: {
5
5
  currency: CurrencyEnum;
6
6
  value: number;
@@ -19,5 +19,29 @@ export declare const availableShippingMethodsFixture: {
19
19
  value: number;
20
20
  currency: CurrencyEnum;
21
21
  };
22
- }[];
22
+ original_amount?: undefined;
23
+ } | {
24
+ amount: {
25
+ currency: CurrencyEnum;
26
+ value: number;
27
+ };
28
+ available: boolean;
29
+ carrier_code: string;
30
+ carrier_title: string;
31
+ error_message: string;
32
+ method_code: string;
33
+ method_title: string;
34
+ original_amount: {
35
+ value: number;
36
+ currency: CurrencyEnum;
37
+ };
38
+ price_excl_tax: {
39
+ value: number;
40
+ currency: CurrencyEnum;
41
+ };
42
+ price_incl_tax: {
43
+ value: number;
44
+ currency: CurrencyEnum;
45
+ };
46
+ })[];
23
47
  //# sourceMappingURL=available-shipping-methods.d.ts.map
@@ -35,7 +35,7 @@ export declare const shippingAddressFixture: {
35
35
  };
36
36
  telephone: string;
37
37
  custom_attributes: never[];
38
- available_shipping_methods: {
38
+ available_shipping_methods: ({
39
39
  amount: {
40
40
  currency: import('../../../__generated__/types').CurrencyEnum;
41
41
  value: number;
@@ -54,7 +54,31 @@ export declare const shippingAddressFixture: {
54
54
  value: number;
55
55
  currency: import('../../../__generated__/types').CurrencyEnum;
56
56
  };
57
- }[];
57
+ original_amount?: undefined;
58
+ } | {
59
+ amount: {
60
+ currency: import('../../../__generated__/types').CurrencyEnum;
61
+ value: number;
62
+ };
63
+ available: boolean;
64
+ carrier_code: string;
65
+ carrier_title: string;
66
+ error_message: string;
67
+ method_code: string;
68
+ method_title: string;
69
+ original_amount: {
70
+ value: number;
71
+ currency: import('../../../__generated__/types').CurrencyEnum;
72
+ };
73
+ price_excl_tax: {
74
+ value: number;
75
+ currency: import('../../../__generated__/types').CurrencyEnum;
76
+ };
77
+ price_incl_tax: {
78
+ value: number;
79
+ currency: import('../../../__generated__/types').CurrencyEnum;
80
+ };
81
+ })[];
58
82
  selected_shipping_method: null;
59
83
  prefix: string;
60
84
  suffix: string;
@@ -4,5 +4,6 @@ declare const flatRate: ShippingMethod;
4
4
  declare const freeShipping: ShippingMethod;
5
5
  declare const standardShipping: ShippingMethod;
6
6
  declare const expressShipping: ShippingMethod;
7
- export { expressShipping, flatRate, freeShipping, standardShipping };
7
+ declare const discountedShipping: ShippingMethod;
8
+ export { discountedShipping, expressShipping, flatRate, freeShipping, standardShipping, };
8
9
  //# sourceMappingURL=shipping.d.ts.map