@dropins/storefront-checkout 2.0.0-beta3 → 2.0.0-beta5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.js +7 -7
- package/chunks/ConditionalWrapper.js +1 -1
- package/chunks/Summary.js +3 -0
- package/chunks/dom.js +3 -0
- package/chunks/events.js +3 -0
- package/components/BillToShippingAddress/BillToShippingAddress.d.ts +4 -1
- package/components/LoginFormSummary/LoginFormSummary.d.ts +10 -0
- package/{tests/utils → components/LoginFormSummary}/index.d.ts +2 -3
- package/components/PaymentMethods/PaymentMethods.d.ts +5 -3
- package/components/PaymentMethodsSummary/PaymentMethodsSummary.d.ts +11 -0
- package/components/PaymentMethodsSummary/index.d.ts +19 -0
- package/components/ShippingMethods/ShippingMethods.d.ts +3 -1
- package/components/ShippingMethodsSummary/ShippingMethodsSummary.d.ts +14 -0
- package/components/ShippingMethodsSummary/index.d.ts +19 -0
- package/components/Summary/Summary.d.ts +10 -0
- package/{msw/fixtures → components/Summary}/index.d.ts +3 -4
- package/components/index.d.ts +4 -0
- package/containers/BillToShippingAddress/BillToShippingAddress.d.ts +7 -2
- package/containers/BillToShippingAddress.js +1 -1
- package/containers/EstimateShipping.js +1 -1
- package/containers/LoginForm/LoginForm.d.ts +14 -2
- package/containers/LoginForm.js +1 -1
- package/containers/LoginFormSummary/LoginFormSummary.d.ts +14 -0
- package/containers/LoginFormSummary/index.d.ts +19 -0
- package/containers/LoginFormSummary.d.ts +3 -0
- package/containers/LoginFormSummary.js +3 -0
- package/containers/OutOfStock.js +1 -1
- package/containers/PaymentMethods/PaymentMethods.d.ts +8 -0
- package/containers/PaymentMethods.js +1 -1
- package/containers/PaymentMethodsSummary/PaymentMethodsSummary.d.ts +18 -0
- package/containers/PaymentMethodsSummary/index.d.ts +19 -0
- package/containers/PaymentMethodsSummary.d.ts +3 -0
- package/containers/PaymentMethodsSummary.js +3 -0
- package/containers/PlaceOrder.js +1 -1
- package/containers/ServerError.js +1 -1
- package/containers/ShippingMethods/ShippingMethods.d.ts +7 -2
- package/containers/ShippingMethods.js +1 -1
- package/containers/ShippingMethodsSummary/ShippingMethodsSummary.d.ts +15 -0
- package/containers/ShippingMethodsSummary/index.d.ts +19 -0
- package/containers/ShippingMethodsSummary.d.ts +3 -0
- package/containers/ShippingMethodsSummary.js +3 -0
- package/containers/TermsAndConditions.js +1 -1
- package/containers/index.d.ts +2 -0
- package/data/models/shipping-estimate.d.ts +2 -1
- package/i18n/en_US.json.d.ts +35 -28
- package/lib/events.d.ts +1 -0
- package/package.json +1 -1
- package/render.js +6 -6
- package/{msw → tests}/fixtures/fragments/index.d.ts +1 -1
- package/tests/fixtures/index.d.ts +21 -0
- package/tests/fixtures/{cart.d.ts → models/cart.d.ts} +2 -2
- package/tests/fixtures/models/customer.d.ts +5 -0
- package/tests/fixtures/models/index.d.ts +21 -0
- package/tests/fixtures/{payments.d.ts → models/payments.d.ts} +1 -1
- package/tests/fixtures/{shipping.d.ts → models/shipping.d.ts} +1 -1
- package/{msw → tests}/fixtures/queries/index.d.ts +1 -1
- package/{msw → tests/mocks}/browser.d.ts +2 -2
- package/tests/fixtures/customer.d.ts +0 -5
- package/tests/utils/expectError.d.ts +0 -25
- package/tests/utils/mockEvents.d.ts +0 -21
- /package/{msw → tests}/fixtures/fragments/available-shipping-methods.d.ts +0 -0
- /package/{msw → tests}/fixtures/fragments/billing-address.d.ts +0 -0
- /package/{msw → tests}/fixtures/fragments/cart.d.ts +0 -0
- /package/{msw → tests}/fixtures/fragments/shipping-address.d.ts +0 -0
- /package/{msw → tests}/fixtures/mutations/estimate-shipping-methods.d.ts +0 -0
- /package/{msw → tests}/fixtures/mutations/index.d.ts +0 -0
- /package/{msw → tests}/fixtures/mutations/set-billing-address.d.ts +0 -0
- /package/{msw → tests}/fixtures/mutations/set-guest-email.d.ts +0 -0
- /package/{msw → tests}/fixtures/mutations/set-payment-method.d.ts +0 -0
- /package/{msw → tests}/fixtures/mutations/set-shipping-address.d.ts +0 -0
- /package/{msw → tests}/fixtures/mutations/set-shipping-methods.d.ts +0 -0
- /package/{msw → tests}/fixtures/queries/get-cart.d.ts +0 -0
- /package/{msw → tests}/fixtures/queries/get-customer.d.ts +0 -0
- /package/{msw → tests}/fixtures/queries/get-store-config.d.ts +0 -0
- /package/{msw → tests}/fixtures/queries/is-email-available.d.ts +0 -0
- /package/{msw → tests/mocks}/handlers.d.ts +0 -0
- /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
|
|
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
|
-
`,
|
|
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
|
-
`,
|
|
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
|
-
${
|
|
56
|
-
`,
|
|
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
|
-
${
|
|
79
|
-
`,
|
|
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{
|
|
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
package/chunks/events.js
ADDED
|
@@ -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
|
|
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 './
|
|
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>, '
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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
|
|
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 './
|
|
18
|
-
export
|
|
19
|
-
export * from './mutations';
|
|
17
|
+
export * from './Summary';
|
|
18
|
+
export { Summary as default } from './Summary';
|
|
20
19
|
//# sourceMappingURL=index.d.ts.map
|
package/components/index.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
package/containers/LoginForm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as r,jsxs as
|
|
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
|
+
/*! 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};
|
package/containers/OutOfStock.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|