@dropins/storefront-checkout 2.0.0-beta3 → 2.0.0-beta4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/api.js +7 -7
  2. package/chunks/ConditionalWrapper.js +1 -1
  3. package/chunks/Summary.js +3 -0
  4. package/chunks/dom.js +3 -0
  5. package/chunks/events.js +3 -0
  6. package/components/BillToShippingAddress/BillToShippingAddress.d.ts +4 -1
  7. package/components/LoginFormSummary/LoginFormSummary.d.ts +10 -0
  8. package/{tests/utils → components/LoginFormSummary}/index.d.ts +2 -3
  9. package/components/PaymentMethods/PaymentMethods.d.ts +5 -3
  10. package/components/PaymentMethodsSummary/PaymentMethodsSummary.d.ts +11 -0
  11. package/components/PaymentMethodsSummary/index.d.ts +19 -0
  12. package/components/ShippingMethods/ShippingMethods.d.ts +3 -1
  13. package/components/ShippingMethodsSummary/ShippingMethodsSummary.d.ts +14 -0
  14. package/components/ShippingMethodsSummary/index.d.ts +19 -0
  15. package/components/Summary/Summary.d.ts +10 -0
  16. package/{msw/fixtures → components/Summary}/index.d.ts +3 -4
  17. package/components/index.d.ts +4 -0
  18. package/containers/BillToShippingAddress/BillToShippingAddress.d.ts +7 -2
  19. package/containers/BillToShippingAddress.js +1 -1
  20. package/containers/EstimateShipping.js +1 -1
  21. package/containers/LoginForm/LoginForm.d.ts +14 -2
  22. package/containers/LoginForm.js +1 -1
  23. package/containers/LoginFormSummary/LoginFormSummary.d.ts +14 -0
  24. package/containers/LoginFormSummary/index.d.ts +19 -0
  25. package/containers/LoginFormSummary.d.ts +3 -0
  26. package/containers/LoginFormSummary.js +3 -0
  27. package/containers/OutOfStock.js +1 -1
  28. package/containers/PaymentMethods/PaymentMethods.d.ts +8 -0
  29. package/containers/PaymentMethods.js +1 -1
  30. package/containers/PaymentMethodsSummary/PaymentMethodsSummary.d.ts +18 -0
  31. package/containers/PaymentMethodsSummary/index.d.ts +19 -0
  32. package/containers/PaymentMethodsSummary.d.ts +3 -0
  33. package/containers/PaymentMethodsSummary.js +3 -0
  34. package/containers/PlaceOrder.js +1 -1
  35. package/containers/ServerError.js +1 -1
  36. package/containers/ShippingMethods/ShippingMethods.d.ts +7 -2
  37. package/containers/ShippingMethods.js +1 -1
  38. package/containers/ShippingMethodsSummary/ShippingMethodsSummary.d.ts +15 -0
  39. package/containers/ShippingMethodsSummary/index.d.ts +19 -0
  40. package/containers/ShippingMethodsSummary.d.ts +3 -0
  41. package/containers/ShippingMethodsSummary.js +3 -0
  42. package/containers/TermsAndConditions.js +1 -1
  43. package/containers/index.d.ts +2 -0
  44. package/data/models/shipping-estimate.d.ts +2 -1
  45. package/i18n/en_US.json.d.ts +35 -28
  46. package/lib/events.d.ts +1 -0
  47. package/package.json +1 -1
  48. package/render.js +6 -6
  49. package/{msw → tests}/fixtures/fragments/index.d.ts +1 -1
  50. package/tests/fixtures/index.d.ts +21 -0
  51. package/tests/fixtures/{cart.d.ts → models/cart.d.ts} +2 -2
  52. package/tests/fixtures/models/customer.d.ts +5 -0
  53. package/tests/fixtures/models/index.d.ts +21 -0
  54. package/tests/fixtures/{payments.d.ts → models/payments.d.ts} +1 -1
  55. package/tests/fixtures/{shipping.d.ts → models/shipping.d.ts} +1 -1
  56. package/{msw → tests}/fixtures/queries/index.d.ts +1 -1
  57. package/{msw → tests/mocks}/browser.d.ts +2 -2
  58. package/tests/fixtures/customer.d.ts +0 -5
  59. package/tests/utils/expectError.d.ts +0 -25
  60. package/tests/utils/mockEvents.d.ts +0 -21
  61. /package/{msw → tests}/fixtures/fragments/available-shipping-methods.d.ts +0 -0
  62. /package/{msw → tests}/fixtures/fragments/billing-address.d.ts +0 -0
  63. /package/{msw → tests}/fixtures/fragments/cart.d.ts +0 -0
  64. /package/{msw → tests}/fixtures/fragments/shipping-address.d.ts +0 -0
  65. /package/{msw → tests}/fixtures/mutations/estimate-shipping-methods.d.ts +0 -0
  66. /package/{msw → tests}/fixtures/mutations/index.d.ts +0 -0
  67. /package/{msw → tests}/fixtures/mutations/set-billing-address.d.ts +0 -0
  68. /package/{msw → tests}/fixtures/mutations/set-guest-email.d.ts +0 -0
  69. /package/{msw → tests}/fixtures/mutations/set-payment-method.d.ts +0 -0
  70. /package/{msw → tests}/fixtures/mutations/set-shipping-address.d.ts +0 -0
  71. /package/{msw → tests}/fixtures/mutations/set-shipping-methods.d.ts +0 -0
  72. /package/{msw → tests}/fixtures/queries/get-cart.d.ts +0 -0
  73. /package/{msw → tests}/fixtures/queries/get-customer.d.ts +0 -0
  74. /package/{msw → tests}/fixtures/queries/get-store-config.d.ts +0 -0
  75. /package/{msw → tests}/fixtures/queries/is-email-available.d.ts +0 -0
  76. /package/{msw → tests/mocks}/handlers.d.ts +0 -0
  77. /package/{msw → tests/mocks}/server.d.ts +0 -0
package/api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{t as y,a as O,b as x}from"./chunks/synchronizeCheckout.js";import{d as et,c as st,g as it,i as rt,e as nt,r as at,s as ot}from"./chunks/synchronizeCheckout.js";import{s as g,M as S,b as G,d as m,Q as C,c as N}from"./chunks/errors.js";import{D as pt,F as ct,I as ht,o as gt,m as mt,n as _t,S as lt,U as ut,j as At,k as ft,l as St,g as Ct,r as Mt,e as Et,f as It,i as Tt}from"./chunks/errors.js";import"@dropins/tools/lib.js";import{t as $,a as v}from"./chunks/setShippingMethods.js";import{s as Ot}from"./chunks/setShippingMethods.js";import{g as M}from"./chunks/values.js";import{events as U}from"@dropins/tools/event-bus.js";import{A as F}from"./chunks/checkout.js";import{g as Gt,i as Nt,s as $t}from"./chunks/setGuestEmailOnCart.js";import{s as Ut}from"./chunks/setBillingAddress.js";import{s as bt}from"./chunks/setPaymentMethod.js";import{CHECKOUT_DATA_FRAGMENT as E}from"./fragments.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const b=`
3
+ import{t as v,a as N,b as $}from"./chunks/synchronizeCheckout.js";import{d as se,c as ie,g as re,i as ae,e as ne,r as oe,s as de}from"./chunks/synchronizeCheckout.js";import{s as h,M as E,b as U,d as g,Q as M,c as b}from"./chunks/errors.js";import{D as ce,F as he,I as ge,o as me,m as le,n as _e,S as ue,U as Ae,j as fe,k as Se,l as Ce,g as Ee,r as Me,e as Ie,f as Te,i as ye}from"./chunks/errors.js";import"@dropins/tools/lib.js";import{t as F,a as S}from"./chunks/setShippingMethods.js";import{s as xe}from"./chunks/setShippingMethods.js";import{events as C}from"@dropins/tools/event-bus.js";import{g as I}from"./chunks/values.js";import{A as w}from"./chunks/checkout.js";import{g as ve,i as Ne,s as $e}from"./chunks/setGuestEmailOnCart.js";import{s as be}from"./chunks/setBillingAddress.js";import{s as we}from"./chunks/setPaymentMethod.js";import{CHECKOUT_DATA_FRAGMENT as T}from"./fragments.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const k=`
4
4
  mutation estimateShippingMethods(
5
5
  $cartId: String!
6
6
  $address: EstimateAddressInput!
@@ -26,7 +26,7 @@ import{t as y,a as O,b as x}from"./chunks/synchronizeCheckout.js";import{d as et
26
26
  error_message
27
27
  }
28
28
  }
29
- `,w=e=>e?e.filter(t=>!!t).map(t=>({id:t.agreement_id,name:t.name,mode:F[t.mode],text:t.checkbox_text,content:{value:t.content,html:t.is_html,height:t.content_height??null}})):[],J=async e=>{var _,l,u,A;const t=g.cartId,r=((_=e==null?void 0:e.criteria)==null?void 0:_.country_code)??((l=g.config)==null?void 0:l.defaultCountry);if(!t)throw new S;if(!r)throw new G;const{region_id:s,region_name:p,zip:n}=(e==null?void 0:e.criteria)??{},i=s||p?{region_id:typeof s=="string"?parseInt(s,10):s,region_code:p}:void 0,o={country_code:r,...n&&{postcode:n},...i&&{region:{...i.region_id&&{region_id:i.region_id},...i.region_code&&{region_code:i.region_code}}}},c={country_id:r,region:(u=o.region)==null?void 0:u.region_code,region_id:(A=o.region)==null?void 0:A.region_id,postcode:n},d=await m({options:{variables:{cartId:t,address:o}},path:"estimateShippingMethods",query:b,queueName:C.ShippingEstimate,transformer:y,type:"mutation"}),I=d.length>0,T=v(c);let h=null;if(I){const a=M("selectedShippingMethod");h=d.find(f=>f.code===(a==null?void 0:a.code)&&f.carrier.code===(a==null?void 0:a.carrier.code))??d[0]}return U.emit("shipping/estimate",{address:T,shippingMethod:h?$(h):null,availableShippingMethods:d}),d},k=`
29
+ `,D=t=>t?t.filter(e=>!!e).map(e=>({id:e.agreement_id,name:e.name,mode:w[e.mode],text:e.checkbox_text,content:{value:e.content,html:e.is_html,height:e.content_height??null}})):[],W=async t=>{var m,l,_,u;const e=h.cartId,a=((m=t==null?void 0:t.criteria)==null?void 0:m.country_code)??((l=h.config)==null?void 0:l.defaultCountry);if(!e)throw new E;if(!a)throw new U;const{region_id:s,region_name:p,zip:n}=(t==null?void 0:t.criteria)??{},i=s||p?{region_id:typeof s=="string"?parseInt(s,10):s,region_code:p}:void 0,d={country_code:a,...n&&{postcode:n},...i&&{region:{...i.region_id&&{region_id:i.region_id},...i.region_code&&{region_code:i.region_code}}}},c={country_id:a,region:(_=d.region)==null?void 0:_.region_code,region_id:(u=d.region)==null?void 0:u.region_id,postcode:n},y=S(c);return g({options:{variables:{cartId:e,address:d}},path:"estimateShippingMethods",query:k,queueName:M.ShippingEstimate,transformer:v,type:"mutation"}).then(r=>{const O=r.length>0,x=S(c);let A=null;if(O){const o=I("selectedShippingMethod"),G=r.find(f=>f.code===(o==null?void 0:o.code)&&f.carrier.code===(o==null?void 0:o.carrier.code));A=F(G??r[0])}return C.emit("shipping/estimate",{address:x,availableShippingMethods:r,shippingMethod:A,success:!0}),r}).catch(r=>{throw C.emit("shipping/estimate",{address:y,shippingMethod:null,availableShippingMethods:[],success:!1}),r})},H=`
30
30
  query GET_CHECKOUT_AGREEMENTS {
31
31
  checkoutAgreements {
32
32
  agreement_id
@@ -38,7 +38,7 @@ import{t as y,a as O,b as x}from"./chunks/synchronizeCheckout.js";import{d as et
38
38
  name
39
39
  }
40
40
  }
41
- `,W=async()=>await m({defaultValueOnFail:[],options:{method:"GET",cache:"no-cache"},path:"checkoutAgreements",query:k,transformer:w,type:"query"}),D=`
41
+ `,X=async()=>await g({defaultValueOnFail:[],options:{method:"GET",cache:"no-cache"},path:"checkoutAgreements",query:H,transformer:D,type:"query"}),R=`
42
42
  mutation setShippingAddress(
43
43
  $cartId: String!
44
44
  $shippingAddressInput: ShippingAddressInput!
@@ -52,8 +52,8 @@ import{t as y,a as O,b as x}from"./chunks/synchronizeCheckout.js";import{d as et
52
52
  }
53
53
  }
54
54
 
55
- ${E}
56
- `,H=`
55
+ ${T}
56
+ `,B=`
57
57
  mutation SET_SHIPPING_ADDRESS_ON_CART_AND_USE_AS_BILLING_MUTATION(
58
58
  $cartId: String!
59
59
  $shippingAddressInput: ShippingAddressInput!
@@ -75,5 +75,5 @@ import{t as y,a as O,b as x}from"./chunks/synchronizeCheckout.js";import{d as et
75
75
  }
76
76
  }
77
77
 
78
- ${E}
79
- `,X=async({address:e,customerAddressId:t,pickupLocationCode:r})=>{const s=g.cartId;if(!s)throw new S;const p=()=>{if(t)return{customer_address_id:t};if(r)return{pickup_location_code:r};if(!e)throw new N;return{address:O(e)}},n=M("isBillToShipping"),i=n?H:D,o=n?"setBillingAddressOnCart.cart":"setShippingAddressesOnCart.cart",c={cartId:s,shippingAddressInput:p()};return await m({type:"mutation",query:i,options:{variables:c},path:o,queueName:C.CartUpdate,transformer:x})};export{pt as DEFAULT_COUNTRY,ct as FetchError,ht as InvalidArgument,gt as MissingBillingAddress,S as MissingCart,G as MissingCountry,mt as MissingEmail,_t as MissingPaymentMethod,N as MissingShippinghAddress,lt as STORE_CONFIG_DEFAULTS,ut as UnexpectedError,et as authenticateCustomer,st as config,J as estimateShippingMethods,At as fetchGraphQl,it as getCart,W as getCheckoutAgreements,ft as getConfig,Gt as getCustomer,St as getStoreConfig,Ct as getStoreConfigCache,rt as initialize,nt as initializeCheckout,Nt as isEmailAvailable,Mt as removeFetchGraphQlHeader,at as resetCheckout,Ut as setBillingAddress,Et as setEndpoint,It as setFetchGraphQlHeader,Tt as setFetchGraphQlHeaders,$t as setGuestEmailOnCart,bt as setPaymentMethod,X as setShippingAddress,Ot as setShippingMethodsOnCart,ot as synchronizeCheckout};
78
+ ${T}
79
+ `,Z=async({address:t,customerAddressId:e,pickupLocationCode:a})=>{const s=h.cartId;if(!s)throw new E;const p=()=>{if(e)return{customer_address_id:e};if(a)return{pickup_location_code:a};if(!t)throw new b;return{address:N(t)}},n=I("isBillToShipping"),i=n?B:R,d=n?"setBillingAddressOnCart.cart":"setShippingAddressesOnCart.cart",c={cartId:s,shippingAddressInput:p()};return await g({type:"mutation",query:i,options:{variables:c},path:d,queueName:M.CartUpdate,transformer:$})};export{ce as DEFAULT_COUNTRY,he as FetchError,ge as InvalidArgument,me as MissingBillingAddress,E as MissingCart,U as MissingCountry,le as MissingEmail,_e as MissingPaymentMethod,b as MissingShippinghAddress,ue as STORE_CONFIG_DEFAULTS,Ae as UnexpectedError,se as authenticateCustomer,ie as config,W as estimateShippingMethods,fe as fetchGraphQl,re as getCart,X as getCheckoutAgreements,Se as getConfig,ve as getCustomer,Ce as getStoreConfig,Ee as getStoreConfigCache,ae as initialize,ne as initializeCheckout,Ne as isEmailAvailable,Me as removeFetchGraphQlHeader,oe as resetCheckout,be as setBillingAddress,Ie as setEndpoint,Te as setFetchGraphQlHeader,ye as setFetchGraphQlHeaders,$e as setGuestEmailOnCart,we as setPaymentMethod,Z as setShippingAddress,xe as setShippingMethodsOnCart,de as synchronizeCheckout};
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{events as s}from"@dropins/tools/event-bus.js";import{jsxs as c,jsx as r}from"@dropins/tools/preact-jsx-runtime.js";function i(){return s.lastPayload("checkout/initialized")??null}function e(){return s.lastPayload("checkout/updated")??null}function f(){var n;const t=e()??i();return!!((n=t==null?void 0:t.shippingAddresses)!=null&&n.length)}function m(){const t=e()??i();return!!(t!=null&&t.isVirtual)}function g(){const t=e()??i();return(t==null?void 0:t.email)??null}function C(t,n){return function(u){const{initialized:o=!0,visible:a=!0,...l}=u;return c("div",{className:"conditional-wrapper",children:[a&&!o&&r(n,{}),a&&o&&r(t,{...l})]})}}export{C as W,g as a,e as g,f as h,m as i};
3
+ import{jsxs as a,jsx as o}from"@dropins/tools/preact-jsx-runtime.js";function l(r,t){return function(e){const{initialized:i=!0,visible:n=!0,...s}=e;return a("div",{className:"conditional-wrapper",children:[n&&!i&&o(t,{}),n&&i&&o(r,{...s})]})}}export{l as W};
@@ -0,0 +1,3 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ import{jsxs as n,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import"./TermsAndConditions.js";import{Button as l}from"@dropins/tools/components.js";import{classes as _,VComponent as d}from"@dropins/tools/lib.js";import{useText as y}from"@dropins/tools/i18n.js";const u=t=>{const i=y({edit:"Checkout.Summary.Edit"});return s(l,{...t,class:"summary__edit","data-testid":"summary-edit-button",size:"medium",variant:"tertiary",children:i.edit})},B=({children:t,className:i,heading:c,onEditClick:o,...a})=>{const m=!!c,r=!!o,e=_(["summary",["summary--inline",!m&&r],i]);return m&&r?n("div",{...a,className:e,children:[n("div",{class:"summary__header",children:[s(d,{node:c}),s(u,{onClick:o})]}),s("div",{class:"summary__content",children:t})]}):!m&&r?n("div",{...a,className:e,children:[s("div",{class:"summary__content",children:t}),s(u,{onClick:o})]}):m&&!r?n("div",{...a,className:e,children:[s("div",{class:"summary__header",children:s(d,{node:c})}),s("div",{class:"summary__content",children:t})]}):s("div",{...a,className:e,children:s("div",{class:"summary__content",children:t})})};export{B as S};
package/chunks/dom.js ADDED
@@ -0,0 +1,3 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ function c(o){o.focus(),document.activeElement!==o&&o.scrollIntoView({behavior:"smooth"})}export{c as s};
@@ -0,0 +1,3 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ import{events as a}from"@dropins/tools/event-bus.js";function i(){return a.lastPayload("checkout/initialized")??null}function u(){return a.lastPayload("checkout/updated")??null}function n(){return u()??i()}function s(){var e;const t=n();return!!((e=t==null?void 0:t.shippingAddresses)!=null&&e.length)}function l(){const t=n();return!!(t!=null&&t.isVirtual)}function r(){const t=n();return(t==null?void 0:t.email)??null}export{n as a,r as b,u as g,s as h,l as i};
@@ -1,8 +1,11 @@
1
1
  import { FunctionComponent } from 'preact';
2
2
  import { HTMLAttributes } from 'preact/compat';
3
3
 
4
- export interface BillToShippingAddressProps extends Omit<HTMLAttributes<HTMLInputElement>, 'loading' | 'disabled'> {
4
+ export interface BillToShippingAddressProps extends Omit<HTMLAttributes<HTMLInputElement>, 'loading' | 'disabled' | 'onChange'> {
5
5
  disabled?: boolean;
6
+ error?: string | null;
7
+ onChange?: (checked: boolean) => void;
8
+ onDismissError?: () => void;
6
9
  }
7
10
  export declare const BillToShippingAddress: FunctionComponent<BillToShippingAddressProps & import('../ConditionalWrapper/ConditionalWrapper').ConditionalProps>;
8
11
  //# sourceMappingURL=BillToShippingAddress.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { FunctionComponent, VNode } from 'preact';
2
+ import { HTMLAttributes } from 'preact/compat';
3
+
4
+ export interface LoginFormSummaryProps extends HTMLAttributes<HTMLDivElement> {
5
+ heading?: VNode;
6
+ email: string;
7
+ onEditClick?: () => void;
8
+ }
9
+ export declare const LoginFormSummary: FunctionComponent<LoginFormSummaryProps>;
10
+ //# sourceMappingURL=LoginFormSummary.d.ts.map
@@ -2,7 +2,7 @@
2
2
  * ADOBE CONFIDENTIAL
3
3
  * __________________
4
4
  *
5
- * Copyright 2024 Adobe
5
+ * Copyright 2025 Adobe
6
6
  * All Rights Reserved.
7
7
  *
8
8
  * NOTICE: All information contained herein is, and remains
@@ -14,6 +14,5 @@
14
14
  * is strictly forbidden unless prior written permission is obtained
15
15
  * from Adobe.
16
16
  *******************************************************************/
17
- export * from './expectError';
18
- export * from './mockEvents';
17
+ export * from './LoginFormSummary';
19
18
  //# sourceMappingURL=index.d.ts.map
@@ -6,9 +6,11 @@ import { HTMLAttributes } from 'preact/compat';
6
6
 
7
7
  interface ExtendedPaymentMethod extends PaymentMethodConfig, PaymentMethod {
8
8
  }
9
- export interface PaymentMethodsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'loading' | 'title'> {
10
- isLoading?: boolean;
11
- onChange?: (value: PaymentMethod) => void;
9
+ export interface PaymentMethodsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'loading' | 'title'> {
10
+ error?: string | null;
11
+ loading?: boolean;
12
+ onDismissError?: () => void;
13
+ onSelectionChange?: (value: PaymentMethod) => void;
12
14
  options?: ExtendedPaymentMethod[];
13
15
  paymentMethodContent?: VNode;
14
16
  selection: PaymentMethod | null;
@@ -0,0 +1,11 @@
1
+ import { FunctionComponent, VNode } from 'preact';
2
+ import { HTMLAttributes } from 'preact/compat';
3
+
4
+ export interface PaymentMethodsSummaryProps extends HTMLAttributes<HTMLDivElement> {
5
+ details: VNode;
6
+ heading?: VNode;
7
+ onEditClick?: () => void;
8
+ }
9
+ export declare const PaymentMethodsSummary: FunctionComponent<PaymentMethodsSummaryProps>;
10
+ export default PaymentMethodsSummary;
11
+ //# sourceMappingURL=PaymentMethodsSummary.d.ts.map
@@ -0,0 +1,19 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export * from './PaymentMethodsSummary';
18
+ export { PaymentMethodsSummary as default } from './PaymentMethodsSummary';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -4,8 +4,10 @@ import { FunctionComponent, VNode } from 'preact';
4
4
  import { HTMLAttributes } from 'preact/compat';
5
5
 
6
6
  export interface ShippingMethodsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
7
- onSelectionChange?: (method: ShippingMethod) => void;
7
+ error?: string | null;
8
8
  isLoading?: boolean;
9
+ onDismissError?: () => void;
10
+ onSelectionChange?: (method: ShippingMethod) => void;
9
11
  options: ShippingMethod[];
10
12
  selection: ShippingMethod | null;
11
13
  title?: VNode;
@@ -0,0 +1,14 @@
1
+ import { FunctionComponent, VNode } from 'preact';
2
+ import { HTMLAttributes } from 'preact/compat';
3
+
4
+ export interface ShippingMethodsSummaryProps extends HTMLAttributes<HTMLDivElement> {
5
+ shippingMethod: {
6
+ label: string;
7
+ description?: string;
8
+ };
9
+ heading?: VNode;
10
+ onEditClick?: () => void;
11
+ }
12
+ export declare const ShippingMethodsSummary: FunctionComponent<ShippingMethodsSummaryProps>;
13
+ export default ShippingMethodsSummary;
14
+ //# sourceMappingURL=ShippingMethodsSummary.d.ts.map
@@ -0,0 +1,19 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export * from './ShippingMethodsSummary';
18
+ export { ShippingMethodsSummary as default } from './ShippingMethodsSummary';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { FunctionalComponent, VNode } from 'preact';
2
+ import { HTMLAttributes } from 'preact/compat';
3
+
4
+ export interface SummaryProps extends HTMLAttributes<HTMLDivElement> {
5
+ heading?: VNode;
6
+ onEditClick?: () => void;
7
+ }
8
+ export declare const Summary: FunctionalComponent<SummaryProps>;
9
+ export default Summary;
10
+ //# sourceMappingURL=Summary.d.ts.map
@@ -2,7 +2,7 @@
2
2
  * ADOBE CONFIDENTIAL
3
3
  * __________________
4
4
  *
5
- * Copyright 2024 Adobe
5
+ * Copyright 2025 Adobe
6
6
  * All Rights Reserved.
7
7
  *
8
8
  * NOTICE: All information contained herein is, and remains
@@ -14,7 +14,6 @@
14
14
  * is strictly forbidden unless prior written permission is obtained
15
15
  * from Adobe.
16
16
  *******************************************************************/
17
- export * from './fragments';
18
- export * from './queries';
19
- export * from './mutations';
17
+ export * from './Summary';
18
+ export { Summary as default } from './Summary';
20
19
  //# sourceMappingURL=index.d.ts.map
@@ -18,11 +18,15 @@ export * from './BillToShippingAddress';
18
18
  export * from './ConditionalWrapper/index';
19
19
  export * from './EstimateShipping';
20
20
  export * from './LoginForm';
21
+ export * from './LoginFormSummary';
21
22
  export * from './Markup';
22
23
  export * from './OutOfStock';
23
24
  export * from './PaymentMethods';
25
+ export * from './PaymentMethodsSummary';
24
26
  export * from './PlaceOrder';
25
27
  export * from './ServerError';
26
28
  export * from './ShippingMethods';
29
+ export * from './ShippingMethodsSummary';
30
+ export * from './Summary';
27
31
  export * from './TermsAndConditions';
28
32
  //# sourceMappingURL=index.d.ts.map
@@ -1,10 +1,15 @@
1
1
  import { Container } from '@dropins/tools/types/elsie/src/lib';
2
+ import { HTMLAttributes } from 'preact/compat';
2
3
 
3
- export interface BillToShippingAddressProps {
4
+ interface CartSyncError {
5
+ error: Error;
6
+ }
7
+ export interface BillToShippingAddressProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
4
8
  active?: boolean;
5
9
  autoSync?: boolean;
10
+ onCartSyncError?: (error: CartSyncError) => void;
6
11
  onChange?: (checked: boolean) => void;
7
- onError?: (error: unknown) => void;
8
12
  }
9
13
  export declare const BillToShippingAddress: Container<BillToShippingAddressProps>;
14
+ export {};
10
15
  //# sourceMappingURL=BillToShippingAddress.d.ts.map
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as a}from"@dropins/tools/preact-jsx-runtime.js";import{h as C}from"../chunks/errors.js";import"@dropins/tools/lib.js";import{events as f}from"@dropins/tools/event-bus.js";import{n as _}from"../chunks/values.js";import{W as z,h as I,g as V}from"../chunks/ConditionalWrapper.js";import{s as N}from"../chunks/setBillingAddress.js";/* empty css */import{Skeleton as U,SkeletonRow as w,Checkbox as y}from"@dropins/tools/components.js";import{c as D}from"../chunks/classes.js";import{useText as P}from"@dropins/tools/i18n.js";import{useState as h,useRef as R,useCallback as u,useEffect as g}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const W=()=>a(U,{className:"bill-to-shipping-address__skeleton","data-testid":"bill-to-shipping-skeleton",children:a(w,{size:"small",variant:"row"})}),j=({className:i,checked:t,disabled:l,onChange:n})=>{const r=P({title:"Checkout.BillToShippingAddress.title"});return a("div",{className:"checkout-bill-to-shipping-address",children:a(y,{checked:t,className:D(["checkout-bill-to-shipping-address__checkbox",i]),"data-testid":"bill-to-shipping-checkbox",disabled:l,label:r.title,name:"checkout-bill-to-shipping-address__checkbox",onChange:n})})},L=z(j,W);function $(i){var r;const t=(r=i.shippingAddresses)==null?void 0:r[0],l=!!i.billingAddress;return(t==null?void 0:t.sameAsBilling)??!l}const es=({active:i=!0,autoSync:t=!0,onChange:l,onError:n})=>{const[r,m]=h(!1),[k,b]=h(!1),[B,A]=h(!0),d=R(!1),S=C.value,c=u(s=>{A(e=>e===s?e:(l==null||l(s),s)),_({isBillToShipping:s})},[l]),T=u(s=>{const o=s.target.checked;c(o),!(!t||!o||!I())&&N({sameAsShipping:!0}).catch(x=>{c(!1),n==null||n(x)})},[t,n,c]),p=u(s=>{const e=!s||(s==null?void 0:s.isEmpty),o=!!(s!=null&&s.isVirtual);if(e||o){b(o),c(!1),d.current=!1;return}d.current||(c($(s)),d.current=!0)},[c]);return g(()=>{if(!i)return;const s=V();if(s){m(!0),p(s);return}const e=f.on("checkout/initialized",o=>{m(!0),p(o)},{eager:!0});return()=>{e==null||e.off()}},[i,p]),g(()=>{if(!i)return;const s=f.on("checkout/updated",p,{eager:!1});return()=>{s==null||s.off()}},[i,p]),a(L,{checked:B,disabled:S,initialized:r,visible:i&&!k,onChange:T})};export{es as BillToShippingAddress,es as default};
3
+ import{jsx as p,jsxs as V}from"@dropins/tools/preact-jsx-runtime.js";import{h as E}from"../chunks/errors.js";import"@dropins/tools/lib.js";import{events as S}from"@dropins/tools/event-bus.js";import{h as N,g as U}from"../chunks/events.js";import{n as j}from"../chunks/values.js";import{s as w}from"../chunks/setBillingAddress.js";/* empty css */import{Skeleton as L,SkeletonRow as P,Checkbox as R,InLineAlert as W}from"@dropins/tools/components.js";import{W as y}from"../chunks/ConditionalWrapper.js";import{c as C}from"../chunks/classes.js";import{useText as x}from"@dropins/tools/i18n.js";import{useState as u,useRef as $,useCallback as m,useEffect 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";const q=()=>p(L,{className:"bill-to-shipping-address__skeleton","data-testid":"bill-to-shipping-skeleton",children:p(P,{size:"small",variant:"row"})}),F=({className:e,checked:r,disabled:t,error:l=null,onChange:o=()=>{},onDismissError:a=()=>{}})=>{const f=x({title:"Checkout.BillToShippingAddress.title"}),h=l!==null,g=k=>{const b=k.target;o==null||o(b.checked)};return V("div",{className:"checkout-bill-to-shipping-address",children:[p(R,{checked:r,className:C(["checkout-bill-to-shipping-address__checkbox",e]),"data-testid":"bill-to-shipping-checkbox",disabled:t,label:f.title,name:"checkout-bill-to-shipping-address__checkbox",onChange:g}),h&&p("div",{className:"checkout-bill-to-shipping-address__error","data-testid":"checkout-bill-to-shipping-address-alert",children:p(W,{heading:l,type:"error",variant:"primary",onDismiss:a})})]})},G=y(F,q);function H(e){var o;const r=(o=e.shippingAddresses)==null?void 0:o[0],t=!!e.billingAddress;return(r==null?void 0:r.sameAsBilling)??!t}const cs=({active:e=!0,autoSync:r=!0,onCartSyncError:t,onChange:l})=>{const[o,a]=u(null),[f,h]=u(!1),[g,k]=u(!1),[b,_]=u(!0),A=$(!1),I=E.value,{cartSyncError:B}=x({cartSyncError:"Checkout.BillToShippingAddress.cartSyncError"}),z=m(()=>{a(null)},[]),n=m(s=>{a(null),_(i=>i===s?i:(l==null||l(s),s)),j({isBillToShipping:s})},[l]),D=m(s=>{const i=s;n(i),!(!r||!i||!N())&&w({sameAsShipping:!0}).catch(c=>{n(!1),t==null||t({error:c}),t||a(B)})},[n,r,t,B]),d=m(s=>{const i=!s||(s==null?void 0:s.isEmpty),c=!!(s!=null&&s.isVirtual);if(i||c){k(c),n(!1),A.current=!1;return}A.current||(n(H(s)),A.current=!0)},[n]);return T(()=>{if(!e)return;const s=U();if(s){h(!0),d(s);return}const i=S.on("checkout/initialized",c=>{h(!0),d(c)},{eager:!0});return()=>{i==null||i.off()}},[e,d]),T(()=>{if(!e)return;const s=S.on("checkout/updated",d,{eager:!1});return()=>{s==null||s.off()}},[e,d]),p(G,{checked:b,disabled:I,error:o,initialized:f,visible:e&&!g,onChange:D,onDismissError:z})};export{cs as BillToShippingAddress,cs as default};
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as i,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Skeleton as B,SkeletonRow as U,Price as h}from"@dropins/tools/components.js";import{W as z,g as G}from"../chunks/ConditionalWrapper.js";import"../chunks/TermsAndConditions.js";import{VComponent as C,classes as D}from"@dropins/tools/lib.js";import{useText as _}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{s as P,T as I}from"../chunks/errors.js";import{events as d}from"@dropins/tools/event-bus.js";import{useState as V,useCallback as b,useEffect as x}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const X=()=>i(B,{"data-testid":"estimate-shipping-skeleton",children:i(U,{size:"xsmall"})}),j=({label:n,price:t,priceExclTax:a,taxExcluded:o=!1,taxIncluded:c=!1})=>{const l=_({withTaxes:"Checkout.EstimateShipping.withTaxes",withoutTaxes:"Checkout.EstimateShipping.withoutTaxes"});return k("div",{className:"checkout-estimate-shipping","data-testid":"estimate-shipping",children:[i(C,{className:"checkout-estimate-shipping__label",node:n}),i(C,{className:"checkout-estimate-shipping__price",node:t}),c&&i("span",{className:D(["checkout-estimate-shipping__caption"]),"data-testid":"shipping-tax-included",children:l.withTaxes}),o&&k("span",{className:D(["checkout-estimate-shipping__caption"]),"data-testid":"shipping-tax-included-excluded",children:[a," ",l.withoutTaxes]})]})},v=z(j,X),nt=({active:n=!0})=>{var T;const[t,a]=V(),o=(t==null?void 0:t.amount.value)===0,c=(T=P.config)==null?void 0:T.shoppingCartDisplaySetting.shipping,l=c===I.INCLUDING_EXCLUDING_TAX,g=c===I.INCLUDING_TAX,u=_({freeShipping:"Checkout.EstimateShipping.freeShipping",taxToBeDetermined:"Checkout.EstimateShipping.taxToBeDetermined",label:"Checkout.EstimateShipping.label",estimated:"Checkout.EstimateShipping.estimated"}),r=b(e=>{var S;const s=!e||e.isEmpty,p=!!(e!=null&&e.isVirtual);if(s||p){a(null);return}const m=(S=e.shippingAddresses)==null?void 0:S[0];if(!m)return;const E=m==null?void 0:m.selectedShippingMethod;if(!E){a(null);return}const{amount:w,amountExclTax:L,amountInclTax:M}=E;a({estimated:!1,amount:w,amountExclTax:L,amountInclTax:M})},[]),f=b(e=>{let s=null;if(e.shippingMethod){const p=e.shippingMethod;s={estimated:!0,amount:p.amount,amountExclTax:p.amountExclTax,amountInclTax:p.amountInclTax}}a(s)},[]);x(()=>{if(!n)return;const e=d.on("shipping/estimate",f,{eager:!0});return()=>{e==null||e.off()}},[n,f]),x(()=>{if(!n)return;const e=G();if(e){r(e);return}const s=d.on("checkout/initialized",r,{eager:!0});return()=>{s==null||s.off()}},[n,r]),x(()=>{if(!n)return;const e=d.on("checkout/updated",r,{eager:!1});return()=>{e==null||e.off()}},[n,r]);const y=()=>o?i("span",{"data-testid":"free-shipping",children:u.freeShipping}):g&&(t!=null&&t.amountInclTax)?i(h,{amount:t.amountInclTax.value,currency:t.amountInclTax.currency,"data-testid":"shipping"}):i(h,{amount:t==null?void 0:t.amount.value,currency:t==null?void 0:t.amount.currency,"data-testid":"shipping"}),N=()=>t!=null&&t.amountExclTax?i(h,{amount:t.amountExclTax.value,currency:t.amountExclTax.currency,"data-testid":"shipping-excluding-tax"}):i("span",{children:u.taxToBeDetermined});return i(v,{initialized:t!==void 0,label:(()=>{const e=t!=null&&t.estimated?u.estimated:u.label;return i("span",{"data-testid":"estimate-shipping-label",children:e})})(),price:y(),priceExclTax:N(),taxExcluded:l&&!o,taxIncluded:g&&!o,visible:n&&t!==null})};export{nt as EstimateShipping,nt as default};
3
+ import{jsx as i,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Skeleton as B,SkeletonRow as U,Price as h}from"@dropins/tools/components.js";import{W as z}from"../chunks/ConditionalWrapper.js";import"../chunks/TermsAndConditions.js";import{VComponent as C,classes as D}from"@dropins/tools/lib.js";import{useText as _}from"@dropins/tools/i18n.js";/* empty css */import{s as G,T as I}from"../chunks/errors.js";import{events as d}from"@dropins/tools/event-bus.js";import{g as P}from"../chunks/events.js";import"@dropins/tools/preact-compat.js";/* empty css *//* empty css */import{useState as V,useCallback as b,useEffect as x}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const X=()=>i(B,{"data-testid":"estimate-shipping-skeleton",children:i(U,{size:"xsmall"})}),j=({label:n,price:t,priceExclTax:a,taxExcluded:o=!1,taxIncluded:c=!1})=>{const l=_({withTaxes:"Checkout.EstimateShipping.withTaxes",withoutTaxes:"Checkout.EstimateShipping.withoutTaxes"});return k("div",{className:"checkout-estimate-shipping","data-testid":"estimate-shipping",children:[i(C,{className:"checkout-estimate-shipping__label",node:n}),i(C,{className:"checkout-estimate-shipping__price",node:t}),c&&i("span",{className:D(["checkout-estimate-shipping__caption"]),"data-testid":"shipping-tax-included",children:l.withTaxes}),o&&k("span",{className:D(["checkout-estimate-shipping__caption"]),"data-testid":"shipping-tax-included-excluded",children:[a," ",l.withoutTaxes]})]})},v=z(j,X),at=({active:n=!0})=>{var T;const[t,a]=V(),o=(t==null?void 0:t.amount.value)===0,c=(T=G.config)==null?void 0:T.shoppingCartDisplaySetting.shipping,l=c===I.INCLUDING_EXCLUDING_TAX,g=c===I.INCLUDING_TAX,u=_({freeShipping:"Checkout.EstimateShipping.freeShipping",taxToBeDetermined:"Checkout.EstimateShipping.taxToBeDetermined",label:"Checkout.EstimateShipping.label",estimated:"Checkout.EstimateShipping.estimated"}),r=b(e=>{var S;const s=!e||e.isEmpty,p=!!(e!=null&&e.isVirtual);if(s||p){a(null);return}const m=(S=e.shippingAddresses)==null?void 0:S[0];if(!m)return;const E=m==null?void 0:m.selectedShippingMethod;if(!E){a(null);return}const{amount:w,amountExclTax:L,amountInclTax:M}=E;a({estimated:!1,amount:w,amountExclTax:L,amountInclTax:M})},[]),f=b(e=>{let s=null;if(e.shippingMethod){const p=e.shippingMethod;s={estimated:!0,amount:p.amount,amountExclTax:p.amountExclTax,amountInclTax:p.amountInclTax}}a(s)},[]);x(()=>{if(!n)return;const e=d.on("shipping/estimate",f,{eager:!0});return()=>{e==null||e.off()}},[n,f]),x(()=>{if(!n)return;const e=P();if(e){r(e);return}const s=d.on("checkout/initialized",r,{eager:!0});return()=>{s==null||s.off()}},[n,r]),x(()=>{if(!n)return;const e=d.on("checkout/updated",r,{eager:!1});return()=>{e==null||e.off()}},[n,r]);const y=()=>o?i("span",{"data-testid":"free-shipping",children:u.freeShipping}):g&&(t!=null&&t.amountInclTax)?i(h,{amount:t.amountInclTax.value,currency:t.amountInclTax.currency,"data-testid":"shipping"}):i(h,{amount:t==null?void 0:t.amount.value,currency:t==null?void 0:t.amount.currency,"data-testid":"shipping"}),N=()=>t!=null&&t.amountExclTax?i(h,{amount:t.amountExclTax.value,currency:t.amountExclTax.currency,"data-testid":"shipping-excluding-tax"}):i("span",{children:u.taxToBeDetermined});return i(v,{initialized:t!==void 0,label:(()=>{const e=t!=null&&t.estimated?u.estimated:u.label;return i("span",{"data-testid":"estimate-shipping-label",children:e})})(),price:y(),priceExclTax:N(),taxExcluded:l&&!o,taxIncluded:g&&!o,visible:n&&t!==null})};export{at as EstimateShipping,at as default};
@@ -2,12 +2,23 @@ import { TitleProps } from '../../types/TitleProps';
2
2
  import { Container, SlotProps } from '@dropins/tools/types/elsie/src/lib';
3
3
  import { HTMLAttributes } from 'preact/compat';
4
4
 
5
+ interface ValidationError {
6
+ email: string;
7
+ message: string;
8
+ type: 'missing' | 'invalid';
9
+ }
10
+ interface CartSyncError {
11
+ email: string;
12
+ error: Error;
13
+ }
5
14
  export interface LoginFormProps extends HTMLAttributes<HTMLFormElement>, TitleProps {
6
- displayHeadingContent?: boolean;
7
15
  active?: boolean;
16
+ autoSync?: boolean;
17
+ displayHeadingContent?: boolean;
8
18
  onSignInClick?: (email: string) => void;
9
19
  onSignOutClick?: () => void;
10
- autoSync?: boolean;
20
+ onCartSyncError?: (error: CartSyncError) => void;
21
+ onValidationError?: (error: ValidationError) => void;
11
22
  slots?: {
12
23
  Heading?: SlotProps<{
13
24
  authenticated: boolean;
@@ -15,4 +26,5 @@ export interface LoginFormProps extends HTMLAttributes<HTMLFormElement>, TitlePr
15
26
  } & TitleProps['slots'];
16
27
  }
17
28
  export declare const LoginForm: Container<LoginFormProps>;
29
+ export {};
18
30
  //# sourceMappingURL=LoginForm.d.ts.map
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as r,jsxs as d,Fragment as Y}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/errors.js";import{VComponent as W,classes as Z,Slot as P}from"@dropins/tools/lib.js";import{events as H}from"@dropins/tools/event-bus.js";import{n as z,g as j}from"../chunks/values.js";import{W as ee,a as te,g as re}from"../chunks/ConditionalWrapper.js";import{i as ie,s as oe,g as ne}from"../chunks/setGuestEmailOnCart.js";import{Field as ae,Input as le,Skeleton as se,SkeletonRow as q}from"@dropins/tools/components.js";import{useText as I}from"@dropins/tools/i18n.js";/* empty css */import"../chunks/TermsAndConditions.js";/* empty css *//* empty css *//* empty css */import{useState as f,useRef as ce,useCallback as g,useEffect as T,useMemo as x}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const me={EMAIL:/^[a-z0-9,!#$%&'*+/=?^_`{|}~-]+(\.[a-z0-9,!#$%&'*+/=?^_`{|}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i},V=a=>me.EMAIL.test(a),ue=({value:a,error:n,hint:c,onChange:u,onBlur:m,onInvalid:s})=>{const l=I({LoginFormLabel:"Checkout.LoginForm.ariaLabel",LoginFormFloatingLabel:"Checkout.LoginForm.floatingLabel",LoginFormPlaceholder:"Checkout.LoginForm.placeholder"});return r(ae,{error:n,hint:c,children:r(le,{"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:a,onBlur:m,onChange:u,onInvalid:s})})},de=({onClick:a})=>{const n=I({account:"Checkout.LoginForm.account",signIn:"Checkout.LoginForm.signIn"});return d("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:c=>{c.preventDefault(),a(c)},children:n.signIn})]})},he=()=>d(se,{"data-testid":"login-form-skeleton",children:[r(q,{fullWidth:!0,variant:"heading"}),r(q,{fullWidth:!0,size:"medium"})]}),ge=({className:a,customer:n,email:c,error:u,headingContent:m,hint:s,name:l,onEmailBlur:k,onEmailChange:N,onEmailInvalid:A,title:L,...y})=>d("div",{className:"checkout-login-form","data-testid":"checkout-login-form",children:[d("div",{className:"checkout-login-form__heading",children:[L&&r(W,{className:"checkout-login-form__title",node:L}),m&&r(W,{className:"checkout-login-form__heading-label",node:m})]}),n?d("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:d("form",{...y,noValidate:!0,className:Z(["dropin-login-form__form",a]),name:l,children:[r("button",{disabled:!0,"aria-hidden":"true",style:"display: none",type:"submit"}),r(ue,{error:u,hint:s,value:c,onBlur:k,onChange:N,onInvalid:A})]})})]}),fe=ee(ge,he),Ee=({onClick:a})=>{const n=I({switch:"Checkout.LoginForm.switch",signOut:"Checkout.LoginForm.signOut"});return d("p",{className:"checkout-login-form__sign-out",children:[n.switch,r("a",{className:"checkout-login-form__link",href:"#",rel:"noreferrer",target:"_blank",onClick:c=>{c.preventDefault(),a==null||a(c)},children:n.signOut})]})},ke=1e3,De=({displayHeadingContent:a=!0,displayTitle:n=!0,initialData:c,onSignInClick:u,onSignOutClick:m,slots:s,active:l=!0,autoSync:k=!0,...N})=>{const[A,L]=f(null),[y,$]=f(""),[O,p]=f(""),[M,R]=f(!1),[B,v]=f(!0),[U,D]=f(!1),h=ce(null),o=I({AlreadyHaveAccountHint:"Checkout.LoginForm.emailExists.alreadyHaveAccount",FasterCheckoutHint:"Checkout.LoginForm.emailExists.forFasterCheckout",InvalidEmailError:"Checkout.LoginForm.invalidEmailError",MissingEmailError:"Checkout.LoginForm.missingEmailError",SignInLabel:"Checkout.LoginForm.emailExists.signInButton",Title:"Checkout.LoginForm.title"}),F=g(e=>{!V(e)||e===te()||(ie(e).then(t=>{v(t)}).catch(t=>{console.error(t),v(!0)}),k&&oe(e).catch(t=>{console.error("Error setting guest email on cart:",t)}))},[k]),G=g(e=>{const i=e.target.value;$(i),v(!0),p(""),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{F(i),z({email:i}),h.current=null},ke)},[F]),S=g(e=>{const t=e.target,i=t.value.trim(),b=V(i);let C="";i===""?C=o.MissingEmailError:b||(C=o.InvalidEmailError),p(C),t.setCustomValidity(C),b&&h.current&&(clearTimeout(h.current),h.current=null,F(i),z({email:i}))},[o.InvalidEmailError,o.MissingEmailError,F]),J=g(e=>{const b=e.target.validity.valueMissing?o.MissingEmailError:o.InvalidEmailError;p(b)},[o.MissingEmailError,o.InvalidEmailError]),_=g(()=>{const e=j("email")??"",t=V(e);u==null||u(t?e:"")},[u]),w=g(()=>{m==null||m()},[m]),E=g(e=>{const t=j("email")??"",i=(e==null?void 0:e.email)??"";i!==t&&($(i),p(""),v(!0),z({email:i}))},[]);T(()=>{if(!l)return;const e=H.on("authenticated",t=>{R(t),ne().then(i=>{L(i)}).catch(console.error)},{eager:!0});return()=>{e==null||e.off()}},[l]),T(()=>{if(!l)return;const e=re();if(e){D(!0),E(e);return}const t=H.on("checkout/initialized",i=>{D(!0),E(i)},{eager:!0});return()=>{t==null||t.off()}},[l,E]),T(()=>{if(!l)return;const e=H.on("checkout/updated",E,{eager:!1});return()=>{e==null||e.off()}},[l,E]);const K=x(()=>{if(n)return r(P,{name:"checkout-login-form-title",slot:s==null?void 0:s.Title,children:r("h2",{children:o.Title})})},[n,s,o.Title]),Q=x(()=>{if(a)return r(P,{context:{authenticated:M},name:"checkout-login-form-heading-label",slot:s==null?void 0:s.Heading,children:M?r(Ee,{onClick:w}):r(de,{onClick:_})})},[a,M,s,_,w]),X=x(()=>B?"":d(Y,{children:[o.AlreadyHaveAccountHint," ",r("a",{href:"#",onClick:_,children:o.SignInLabel})," ",o.FasterCheckoutHint]}),[B,o.AlreadyHaveAccountHint,o.SignInLabel,o.FasterCheckoutHint,_]);return r(fe,{...N,customer:A,email:y,error:O,headingContent:Q,hint:X,initialized:U,title:K,visible:l,onEmailBlur:S,onEmailChange:G,onEmailInvalid:J})};export{De as LoginForm,De as default};
3
+ import{jsx as r,jsxs as u,Fragment as le}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/errors.js";import{VComponent as G,classes as se,Slot as J}from"@dropins/tools/lib.js";import{events as T}from"@dropins/tools/event-bus.js";import{b as ce,g as me}from"../chunks/events.js";import{n as H,g as K}from"../chunks/values.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";/* empty css */import{W as ke}from"../chunks/ConditionalWrapper.js";import"../chunks/TermsAndConditions.js";/* empty css */import"@dropins/tools/preact-compat.js";/* empty css *//* empty css */import{useState as k,useRef as Le,useCallback as d,useEffect as M,useMemo as $}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const ve={EMAIL:/^[a-z0-9,!#$%&'*+/=?^_`{|}~-]+(\.[a-z0-9,!#$%&'*+/=?^_`{|}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i},B=n=>ve.EMAIL.test(n),Fe=({value:n,error:o,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:o,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:n,onBlur:L,onChange:g,onInvalid:c})})},_e=({onClick:n})=>{const o=I({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:a=>{a.preventDefault(),n(a)},children:o.signIn})]})},be=()=>u(pe,{"data-testid":"login-form-skeleton",children:[r(Q,{fullWidth:!0,variant:"heading"}),r(Q,{fullWidth:!0,size:"medium"})]}),Ee=({className:n,customer:o,email:a,error:g,headingContent:L,hint:c,name:l,onEmailBlur:f,onEmailChange:m,onEmailInvalid:s,title:F,...A})=>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})]}),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",{...A,noValidate:!0,className:se(["dropin-login-form__form",n]),name:l,children:[r("button",{disabled:!0,"aria-hidden":"true",style:"display: none",type:"submit"}),r(Fe,{error:g,hint:c,value:a,onBlur:f,onChange:m,onInvalid:s})]})})]}),Ce=ke(Ee,be),Ne=({onClick:n})=>{const o=I({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:a=>{a.preventDefault(),n==null||n(a)},children:o.signOut})]})},Ie=1e3,Ke=({active:n=!0,autoSync:o=!0,displayHeadingContent:a=!0,displayTitle:g=!0,initialData:L,onCartSyncError:c,onSignInClick:l,onSignOutClick:f,onValidationError:m,slots:s,...F})=>{const[A,X]=k(null),[Y,D]=k(""),[Z,p]=k(""),[y,S]=k(!1),[w,_]=k(!0),[ee,V]=k(!1),h=Le(null),{alreadyHaveAccountHint:W,cartSyncError:P,defaultTitle:j,fasterCheckoutHint:q,invalidEmailError:b,missingEmailError:E,signInLabel:O}=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=>{!B(e)||e===ce()||(ue(e).then(t=>{_(t)}).catch(t=>{console.error(t),_(!0)}),o&&he(e).catch(t=>{c==null||c({email:e,error:t}),c||p(P)}))},[o,c,P]),te=d(e=>{const i=e.target.value;D(i),_(!0),p(""),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{C(i),H({email:i}),h.current=null},Ie)},[C]),ie=d(e=>{const t=e.target,i=t.value.trim();if(B(i)){if(p(""),t.setCustomValidity(""),!h.current)return;clearTimeout(h.current),h.current=null,C(i),H({email:i});return}const U=i===""?"missing":"invalid",x=U==="missing"?E:b;if(m){m({email:i,message:x,type:U});return}p(x),t.setCustomValidity(x)},[b,E,m,C]),re=d(e=>{const t=e.target,i=t.validity,z=i.valueMissing?E:b;if(!m){p(z);return}m({email:t.value,message:z,type:i.valueMissing?"missing":"invalid"})},[E,b,m]),N=d(()=>{const e=K("email")??"",t=B(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&&(D(i),p(""),_(!0),H({email:i}))},[]);M(()=>{if(!n)return;const e=T.on("authenticated",t=>{S(t),de().then(i=>{X(i)}).catch(console.error)},{eager:!0});return()=>{e==null||e.off()}},[n]),M(()=>{if(!n)return;const e=me();if(e){V(!0),v(e);return}const t=T.on("checkout/initialized",i=>{V(!0),v(i)},{eager:!0});return()=>{t==null||t.off()}},[n,v]),M(()=>{if(!n)return;const e=T.on("checkout/updated",v,{eager:!1});return()=>{e==null||e.off()}},[n,v]);const ne=$(()=>{if(g)return r(J,{name:"checkout-login-form-title",slot:s==null?void 0:s.Title,children:r("h2",{children:j})})},[g,s,j]),oe=$(()=>{if(a)return r(J,{context:{authenticated:y},name:"checkout-login-form-heading-label",slot:s==null?void 0:s.Heading,children:y?r(Ne,{onClick:R}):r(_e,{onClick:N})})},[a,y,s,N,R]),ae=$(()=>w?"":u(le,{children:[W," ",r("a",{href:"#",onClick:N,children:O})," ",q]}),[w,W,O,q,N]);return r(Ce,{...F,customer:A,email:Y,error:Z,headingContent:oe,hint:ae,initialized:ee,title:ne,visible:n,onEmailBlur:ie,onEmailChange:te,onEmailInvalid:re})};export{Ke as LoginForm,Ke as default};
@@ -0,0 +1,14 @@
1
+ import { Container, SlotProps } from '@dropins/tools/types/elsie/src/lib';
2
+ import { HTMLAttributes } from 'preact/compat';
3
+
4
+ export interface LoginFormSummaryProps extends HTMLAttributes<HTMLDivElement> {
5
+ onEditClick?: () => void;
6
+ slots?: {
7
+ Heading: SlotProps;
8
+ };
9
+ }
10
+ export interface LoginFormSummaryData {
11
+ email: string;
12
+ }
13
+ export declare const LoginFormSummary: Container<LoginFormSummaryProps, LoginFormSummaryData>;
14
+ //# sourceMappingURL=LoginFormSummary.d.ts.map
@@ -0,0 +1,19 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export * from './LoginFormSummary';
18
+ export { LoginFormSummary as default } from './LoginFormSummary';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './LoginFormSummary/index'
2
+ import _default from './LoginFormSummary/index'
3
+ export default _default
@@ -0,0 +1,3 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ import{jsx as t}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import"@dropins/tools/components.js";import"../chunks/TermsAndConditions.js";import{Slot as u}from"@dropins/tools/lib.js";import{c as p}from"../chunks/classes.js";/* empty css */import"../chunks/errors.js";import{events as f}from"@dropins/tools/event-bus.js";import"@dropins/tools/preact-compat.js";/* empty css *//* empty css */import{useState as l,useCallback as g,useEffect as h}from"@dropins/tools/preact-hooks.js";import{S as y}from"../chunks/Summary.js";import{a as S}from"../chunks/events.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/i18n.js";const d=({className:m,heading:r,email:o,onEditClick:e})=>t(y,{className:p([m,"checkout-login-form-summary"]),"data-testid":"checkout-login-form-summary",heading:r,onEditClick:e,children:t("span",{className:"checkout-login-form-summary__email","data-testid":"checkout-login-form-summary-email",children:o})}),k=({initialData:m,onEditClick:r,slots:o})=>{const[e,a]=l((m==null?void 0:m.email)??""),n=g(()=>{r==null||r()},[r]);if(h(()=>{const i=f.on("checkout/updated",s=>{a((s==null?void 0:s.email)??"")});return()=>{i==null||i.off()}},[]),e==="")return null;const c=o!=null&&o.Heading?t(u,{name:"LoginFormHeadingTitle",slot:o.Heading}):void 0;return t(d,{email:e,heading:c,onEditClick:n})};k.getInitialData=async()=>{const m=S();return Promise.resolve({email:(m==null?void 0:m.email)??""})};export{k as LoginFormSummary,k as default};
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as n,jsx as o}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Card as l,Icon as h,Image as O}from"@dropins/tools/components.js";import"../chunks/TermsAndConditions.js";import{classes as d}from"@dropins/tools/lib.js";import{S as p}from"../chunks/OrderError.js";import{useText as S}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{events as _}from"@dropins/tools/event-bus.js";import{useState as g,useCallback as v,useEffect as N}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";const w=({className:r,items:u,onRemoveOutOfStock:s,routeCart:t,...m})=>{const i=S({title:"Checkout.OutOfStock.title",message:"Checkout.OutOfStock.message",reviewCart:"Checkout.OutOfStock.actions.reviewCart",removeOutOfStock:"Checkout.OutOfStock.actions.removeOutOfStock"});return n(l,{className:d(["checkout-out-of-stock",r]),"data-testid":"checkout-out-of-stock",variant:"secondary",...m,children:[n("h4",{className:"checkout-out-of-stock__title",children:[o(h,{size:"16",source:p,stroke:"1"}),i.title]}),o("p",{className:"checkout-out-of-stock__message",children:i.message}),o("ol",{className:"checkout-out-of-stock__items",children:u.map(a=>o("li",{className:"checkout-out-of-stock__item","data-testid":"out-of-stock-item",children:o(O,{alt:a.image.alt,height:"100",loading:"eager",params:{width:100},src:a.image.src,width:"100"})},a.sku))}),n("div",{className:"checkout-out-of-stock__actions",children:[t&&o("a",{className:"checkout-out-of-stock__action","data-testid":"review-cart",href:t,children:i.reviewCart}),s&&o("button",{className:"checkout-out-of-stock__action","data-testid":"remove-out-of-stock",type:"button",onClick:s,children:i.removeOutOfStock})]})]})},A=({onCartProductsUpdate:r,routeCart:u,active:s=!0})=>{const[t,m]=g([]),i=v(()=>{if(!r)return;const e=t.filter(c=>c.outOfStock).map(c=>({uid:c.uid,quantity:0}));r(e)},[t,r]);if(N(()=>{if(!s)return;const e=_.on("cart/data",c=>{const k=(c==null?void 0:c.items)||[];m(k.filter(f=>f.outOfStock||f.insufficientQuantity))},{eager:!0});return()=>{e==null||e.off()}},[s]),!s||t.length===0)return null;const a=!t.some(e=>e.insufficientQuantity);return o(w,{items:t,routeCart:u==null?void 0:u(),onRemoveOutOfStock:a?i:void 0})};export{A as OutOfStock,A as default};
3
+ import{jsxs as n,jsx as o}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Card as l,Icon as h,Image as O}from"@dropins/tools/components.js";import"../chunks/TermsAndConditions.js";import{classes as d}from"@dropins/tools/lib.js";import{S as p}from"../chunks/OrderError.js";import{useText as S}from"@dropins/tools/i18n.js";/* empty css */import"../chunks/errors.js";import{events as _}from"@dropins/tools/event-bus.js";import"@dropins/tools/preact-compat.js";/* empty css *//* empty css */import{useState as g,useCallback as v,useEffect as N}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const w=({className:r,items:u,onRemoveOutOfStock:s,routeCart:t,...a})=>{const i=S({title:"Checkout.OutOfStock.title",message:"Checkout.OutOfStock.message",reviewCart:"Checkout.OutOfStock.actions.reviewCart",removeOutOfStock:"Checkout.OutOfStock.actions.removeOutOfStock"});return n(l,{className:d(["checkout-out-of-stock",r]),"data-testid":"checkout-out-of-stock",variant:"secondary",...a,children:[n("h4",{className:"checkout-out-of-stock__title",children:[o(h,{size:"16",source:p,stroke:"1"}),i.title]}),o("p",{className:"checkout-out-of-stock__message",children:i.message}),o("ol",{className:"checkout-out-of-stock__items",children:u.map(m=>o("li",{className:"checkout-out-of-stock__item","data-testid":"out-of-stock-item",children:o(O,{alt:m.image.alt,height:"100",loading:"eager",params:{width:100},src:m.image.src,width:"100"})},m.sku))}),n("div",{className:"checkout-out-of-stock__actions",children:[t&&o("a",{className:"checkout-out-of-stock__action","data-testid":"review-cart",href:t,children:i.reviewCart}),s&&o("button",{className:"checkout-out-of-stock__action","data-testid":"remove-out-of-stock",type:"button",onClick:s,children:i.removeOutOfStock})]})]})},G=({onCartProductsUpdate:r,routeCart:u,active:s=!0})=>{const[t,a]=g([]),i=v(()=>{if(!r)return;const e=t.filter(c=>c.outOfStock).map(c=>({uid:c.uid,quantity:0}));r(e)},[t,r]);if(N(()=>{if(!s)return;const e=_.on("cart/data",c=>{const k=(c==null?void 0:c.items)||[];a(k.filter(f=>f.outOfStock||f.insufficientQuantity))},{eager:!0});return()=>{e==null||e.off()}},[s]),!s||t.length===0)return null;const m=!t.some(e=>e.insufficientQuantity);return o(w,{items:t,routeCart:u==null?void 0:u(),onRemoveOutOfStock:m?i:void 0})};export{G as OutOfStock,G as default};
@@ -1,3 +1,4 @@
1
+ import { PaymentMethod } from '../../data/models/payment-method';
1
2
  import { UIComponentType } from '../../types/ComponentTypes';
2
3
  import { TitleProps } from '../../types/TitleProps';
3
4
  import { Container, SlotProps } from '@dropins/tools/types/elsie/src/lib';
@@ -17,6 +18,10 @@ export interface PaymentMethodConfig {
17
18
  export interface PaymentMethodsSlot {
18
19
  [code: string]: PaymentMethodConfig;
19
20
  }
21
+ interface CartSyncError {
22
+ method: PaymentMethod;
23
+ error: Error;
24
+ }
20
25
  export interface PaymentMethodsProps extends HTMLAttributes<HTMLDivElement>, TitleProps {
21
26
  slots?: {
22
27
  Methods?: PaymentMethodsSlot;
@@ -24,6 +29,9 @@ export interface PaymentMethodsProps extends HTMLAttributes<HTMLDivElement>, Tit
24
29
  UIComponentType?: UIComponentType;
25
30
  active?: boolean;
26
31
  autoSync?: boolean;
32
+ onCartSyncError?: (error: CartSyncError) => void;
33
+ onSelectionChange?: (method: PaymentMethod) => void;
27
34
  }
28
35
  export declare const PaymentMethods: Container<PaymentMethodsProps>;
36
+ export {};
29
37
  //# sourceMappingURL=PaymentMethods.d.ts.map
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as w,jsx as n}from"@dropins/tools/preact-jsx-runtime.js";import{h as D,s as $}from"../chunks/errors.js";import{classes as E,VComponent as F,Slot as z}from"@dropins/tools/lib.js";import{events as H}from"@dropins/tools/event-bus.js";import{n as G,g as J}from"../chunks/values.js";import{W as K,i as Q,h as X,g as Y}from"../chunks/ConditionalWrapper.js";import{s as ee}from"../chunks/setPaymentMethod.js";/* empty css */import{Skeleton as te,SkeletonRow as C,IllustratedMessage as ne,Icon as N,ProgressSpinner as oe,ToggleButton as re,RadioButton as ae}from"@dropins/tools/components.js";import*as S from"@dropins/tools/preact-compat.js";import{useText as O}from"@dropins/tools/i18n.js";import{useState as _,useCallback as v,useEffect as L,useMemo as ce}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const ie=t=>S.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},S.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"}),S.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),S.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),se=()=>w(te,{"data-testid":"payment-methods-skeleton",children:[n(C,{size:"medium",variant:"heading"}),n(C,{size:"medium",variant:"empty"}),n(C,{fullWidth:!0,size:"xlarge"}),n(C,{fullWidth:!0,size:"xlarge"})]}),le=({code:t,icon:o,isLoading:d,onChange:r,selected:a,title:m,UIComponentType:p="ToggleButton"})=>{const c={busy:d,className:"checkout-payment-methods__method",label:m,name:"payment-method",value:t,onChange:()=>r({code:t,title:m})};return p==="ToggleButton"?n(re,{...c,icon:o?n(N,{source:o}):void 0,selected:a}):n(ae,{...c,checked:a,icon:o??void 0})},de=({className:t,title:o,isLoading:d=!1,onChange:r=()=>{},options:a,paymentMethodContent:m,UIComponentType:p,selection:c})=>{const P=O({EmptyState:"Checkout.PaymentMethods.emptyState"});return w("div",{className:E(["checkout-payment-methods",t]),"data-testid":"checkout-payment-methods",children:[o&&n(F,{className:"checkout-payment-methods__title",node:o}),!d&&a.length===0&&n(ne,{"data-testid":"checkout-payment-methods-empty",icon:n(N,{source:ie}),message:n("p",{children:P.EmptyState})}),w("div",{className:E(["checkout-payment-methods__wrapper",["checkout-payment-methods__wrapper--loading",d]]),children:[d&&n(oe,{className:"checkout-payment-methods__spinner"}),n("div",{className:E(["checkout-payment-methods__methods",["checkout-payment-methods--full-width",a.length%2!==0]]),children:a==null?void 0:a.map(u=>n(le,{UIComponentType:p,code:u.code,icon:u.icon,selected:(c==null?void 0:c.code)===u.code,title:u.displayLabel??!0?u.title:"",onChange:r},u.code))}),m&&n("div",{className:"checkout-payment-methods__content",children:m})]})]})},me=K(de,se);function ue(t,o){return t?o.some(d=>d.code===t.code):!1}function he(t,o){return!t||!o?!1:t.code===o.code}function pe(t){return t?!!t.code&&!!t.title:!1}const Ie=({displayTitle:t=!0,active:o=!0,UIComponentType:d="ToggleButton",slots:r,autoSync:a=!0})=>{var I,b;const[m,p]=_(!1),[c,P]=_(null),[u,U]=_([]),i=r==null?void 0:r.Methods,B=D.value,j=u.filter(e=>{var s;return((s=i==null?void 0:i[e.code])==null?void 0:s.enabled)!==!1}).map(e=>{const s=(i==null?void 0:i[e.code])||{};return{...e,...s}}),V=O({Title:"Checkout.PaymentMethods.title"}),h=v(e=>{P(e),G({selectedPaymentMethod:e})},[]),y=v(async e=>{if(!(Q()||X()))return;const l=i==null?void 0:i[e.code];((l==null?void 0:l.autoSync)??a)&&await ee({code:e.code}).catch(console.error)},[a,i]),A=v(async e=>{h(e),await y(e)},[h,y]),k=v(e=>{if(!e||e.isEmpty){h(null),U([]);return}const l=e.availablePaymentMethods??[];if(U(l),l.length===0){h(null);return}const g=e.selectedPaymentMethod??null,x=pe(g),f=J("selectedPaymentMethod"),T=ue(f,l),q=he(f,g);if(f&&T&&!q){y(f);return}if((!f||!T)&&x){h(g);return}if((!f||!T)&&!x){const W=l[0];h(W),y(W)}},[h,y]);L(()=>{if(!o)return;const e=Y();if(e){p(!0),k(e);return}const s=H.on("checkout/initialized",l=>{p(!0),k(l)},{eager:!0});return()=>{s==null||s.off()}},[o,k]),L(()=>{if(!o)return;const e=H.on("checkout/updated",k,{eager:!1});return()=>{e==null||e.off()}},[o,k]);const M=c?(b=(I=r==null?void 0:r.Methods)==null?void 0:I[c.code])==null?void 0:b.render:null,R=M?n(z,{context:{cartId:$.cartId??"",replaceHTML(e){this.replaceWith(e)}},name:"PaymentMethodContent",slot:M},M):void 0,Z=ce(()=>{if(t)return n(z,{name:"checkout-payment-methods-title",slot:r==null?void 0:r.Title,children:n("h2",{children:V.Title})})},[t,r==null?void 0:r.Title,V.Title]);return n(me,{UIComponentType:d,initialized:m,isLoading:m&&B,options:j,paymentMethodContent:R,selection:c,title:Z,visible:o,onChange:A})};export{Ie as PaymentMethods,Ie as default};
3
+ import{jsxs as x,jsx as t}from"@dropins/tools/preact-jsx-runtime.js";import{h as X,s as Y}from"../chunks/errors.js";import{classes as L,VComponent as ee,Slot as B}from"@dropins/tools/lib.js";import{events as j}from"@dropins/tools/event-bus.js";import{i as te,h as ne,g as oe}from"../chunks/events.js";import{n as re,g as A}from"../chunks/values.js";import{s as ae}from"../chunks/setPaymentMethod.js";import{W as se}from"../chunks/ConditionalWrapper.js";/* empty css */import{Skeleton as ce,SkeletonRow as _,IllustratedMessage as ie,Icon as D,ProgressSpinner as le,InLineAlert as me,ToggleButton as de,RadioButton as ue}from"@dropins/tools/components.js";import{s as he}from"../chunks/dom.js";import*as T from"@dropins/tools/preact-compat.js";import{useRef as pe,useEffect as fe}from"@dropins/tools/preact-compat.js";import{useText as Z}from"@dropins/tools/i18n.js";import{useState as w,useCallback as P,useEffect as R,useMemo as ye}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const ke=n=>T.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},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"})),ge=()=>x(ce,{"data-testid":"payment-methods-skeleton",children:[t(_,{size:"medium",variant:"heading"}),t(_,{size:"medium",variant:"empty"}),t(_,{fullWidth:!0,size:"xlarge"}),t(_,{fullWidth:!0,size:"xlarge"})]}),ve=({UIComponentType:n="ToggleButton",code:r,icon:c,onSelectionChange:y,selected:o,title:a})=>{const i={className:"checkout-payment-methods__method",label:a,name:"payment-method",value:r,onChange:()=>y({code:r,title:a})};return n==="ToggleButton"?t(de,{...i,icon:c?t(D,{source:c}):void 0,selected:o}):t(ue,{...i,checked:o,icon:c??void 0})},Se=({className:n,error:r=null,loading:c=!1,onDismissError:y,onSelectionChange:o=()=>{},options:a,paymentMethodContent:i,selection:g,title:k,UIComponentType:C})=>{const E=Z({EmptyState:"Checkout.PaymentMethods.emptyState"}),p=r!==null,v=pe(null);return fe(()=>{p&&v.current&&he(v.current)},[p]),x("div",{className:L(["checkout-payment-methods",n]),"data-testid":"checkout-payment-methods",children:[k&&t(ee,{className:"checkout-payment-methods__title",node:k}),!c&&a.length===0&&t(ie,{"data-testid":"checkout-payment-methods-empty",icon:t(D,{source:ke}),message:t("p",{children:E.EmptyState})}),x("div",{className:L(["checkout-payment-methods__wrapper",["checkout-payment-methods__wrapper--loading",c]]),children:[c&&t(le,{className:"checkout-payment-methods__spinner"}),t("div",{className:L(["checkout-payment-methods__methods",["checkout-payment-methods--full-width",a.length%2!==0]]),children:a==null?void 0:a.map(d=>t(ve,{UIComponentType:C,code:d.code,icon:d.icon,selected:(g==null?void 0:g.code)===d.code,title:d.displayLabel??!0?d.title:"",onSelectionChange:o},d.code))}),i&&t("div",{className:"checkout-payment-methods__content",children:i})]}),p&&t("div",{ref:v,className:"checkout-payment-methods__error","data-testid":"checkout-payment-methods-alert",children:t(me,{heading:r,type:"error",variant:"primary",onDismiss:y})})]})},Me=se(Se,ge);function Pe(n,r){return n?r.some(c=>c.code===n.code):!1}function Ce(n,r){return!n||!r?!1:n.code===r.code}function Ee(n){return n?!!n.code&&!!n.title:!1}const De=({UIComponentType:n="ToggleButton",active:r=!0,autoSync:c=!0,displayTitle:y=!0,slots:o,onCartSyncError:a,onSelectionChange:i})=>{var H,N;const[g,k]=w(null),[C,E]=w(!1),[p,v]=w(null),[d,W]=w([]),l=o==null?void 0:o.Methods,$=X.value,q=d.filter(e=>{var s;return((s=l==null?void 0:l[e.code])==null?void 0:s.enabled)!==!1}).map(e=>{const s=(l==null?void 0:l[e.code])||{};return{...e,...s}}),{cartSyncError:b,defaultTitle:z}=Z({cartSyncError:"Checkout.PaymentMethods.cartSyncError",defaultTitle:"Checkout.PaymentMethods.title"}),F=P(()=>{k(null)},[]),m=P(e=>{k(null),v(e),re({selectedPaymentMethod:e})},[]),S=P(async(e,s)=>{if(!(te()||ne()))return;const u=l==null?void 0:l[e.code];((u==null?void 0:u.autoSync)??c)&&ae({code:e.code}).catch(h=>{m(s??null),a==null||a({method:e,error:h}),a||k(b)})},[l,c,m,a,b]),G=P(async e=>{const s=A("selectedPaymentMethod");m(e),i==null||i(e),await S(e,s)},[i,m,S]),M=P(e=>{if(!e||e.isEmpty){m(null),W([]);return}const f=e.availablePaymentMethods??[];if(W(f),f.length===0){m(null);return}const u=e.selectedPaymentMethod??null,U=Ee(u),h=A("selectedPaymentMethod"),V=Pe(h,f),Q=Ce(h,u);if(h&&V&&!Q){S(h,u);return}if((!h||!V)&&U){m(u);return}if((!h||!V)&&!U){const O=f[0];m(O),S(O)}},[m,S]);R(()=>{if(!r)return;const e=oe();if(e){E(!0),M(e);return}const s=j.on("checkout/initialized",f=>{E(!0),M(f)},{eager:!0});return()=>{s==null||s.off()}},[r,M]),R(()=>{if(!r)return;const e=j.on("checkout/updated",M,{eager:!1});return()=>{e==null||e.off()}},[r,M]);const I=p?(N=(H=o==null?void 0:o.Methods)==null?void 0:H[p.code])==null?void 0:N.render:null,J=I?t(B,{context:{cartId:Y.cartId??"",replaceHTML(e){this.replaceWith(e)}},name:"PaymentMethodContent",slot:I},I):void 0,K=ye(()=>{if(y)return t(B,{name:"checkout-payment-methods-title",slot:o==null?void 0:o.Title,children:t("h2",{children:z})})},[y,o==null?void 0:o.Title,z]);return t(Me,{UIComponentType:n,error:g,initialized:C,loading:C&&$,options:q,paymentMethodContent:J,selection:p,title:K,visible:r,onDismissError:F,onSelectionChange:G})};export{De as PaymentMethods,De as default};
@@ -0,0 +1,18 @@
1
+ import { PaymentMethod } from '../../data/models';
2
+ import { Container, SlotProps } from '@dropins/tools/types/elsie/src/lib';
3
+ import { HTMLAttributes } from 'preact/compat';
4
+
5
+ export interface PaymentMethodsSummaryData {
6
+ selectedPaymentMethod: PaymentMethod | null;
7
+ }
8
+ export interface PaymentMethodsSummaryProps extends HTMLAttributes<HTMLDivElement> {
9
+ onEditClick?: () => void;
10
+ slots?: {
11
+ Heading?: SlotProps;
12
+ Details?: SlotProps<{
13
+ selectedPaymentMethod: PaymentMethod;
14
+ }>;
15
+ };
16
+ }
17
+ export declare const PaymentMethodsSummary: Container<PaymentMethodsSummaryProps, PaymentMethodsSummaryData>;
18
+ //# sourceMappingURL=PaymentMethodsSummary.d.ts.map