@dropins/storefront-checkout 1.3.0-beta1 → 1.3.0
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/containers/BillToShippingAddress/BillToShippingAddress.d.ts +1 -1
- package/containers/BillToShippingAddress.js +1 -1
- package/containers/MergedCartBanner/MergedCartBanner.d.ts +1 -1
- package/containers/MergedCartBanner.js +1 -1
- package/containers/OutOfStock.js +1 -1
- package/containers/PaymentMethods.js +1 -1
- package/containers/PlaceOrder.js +1 -1
- package/containers/ShippingMethods.js +1 -1
- package/containers/TermsAndConditions/TermsAndConditions.d.ts +1 -1
- package/containers/TermsAndConditions.js +1 -1
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ export interface BillToShippingAddressProps {
|
|
|
18
18
|
onChange?: (checked: boolean) => void;
|
|
19
19
|
}
|
|
20
20
|
export declare const BillToShippingAddress: {
|
|
21
|
-
({ hideOnEmptyCart, hideOnVirtualCart, ...props }: import('../../hocs/withConditionalRendering').ConditionalProps & BillToShippingAddressProps): import("preact
|
|
21
|
+
({ hideOnEmptyCart, hideOnVirtualCart, ...props }: import('../../hocs/withConditionalRendering').ConditionalProps & BillToShippingAddressProps): import("preact").JSX.Element;
|
|
22
22
|
displayName: string;
|
|
23
23
|
};
|
|
24
24
|
//# sourceMappingURL=BillToShippingAddress.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as t}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/state.js";import{i as d,c as u}from"../chunks/transform-store-config.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import{s as S}from"../chunks/setBillingAddress.js";/* empty css */import{Checkbox as b,Skeleton as f,SkeletonRow as A}from"@dropins/tools/components.js";import{c as B}from"../chunks/classes.js";import{useText as x}from"@dropins/tools/i18n.js";import{w as T}from"../chunks/withConditionalRendering.js";import{useState as v,useEffect as _}from"@dropins/tools/preact-
|
|
3
|
+
import{jsx as t}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/state.js";import{i as d,c as u}from"../chunks/transform-store-config.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import{s as S}from"../chunks/setBillingAddress.js";/* empty css */import{Checkbox as b,Skeleton as f,SkeletonRow as A}from"@dropins/tools/components.js";import{c as B}from"../chunks/classes.js";import{useText as x}from"@dropins/tools/i18n.js";import{w as T}from"../chunks/withConditionalRendering.js";import{useState as v,useEffect as _}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/store-config.js";import"@dropins/tools/signals.js";import"../chunks/errors.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const w=({className:i,checked:e,loading:r,disabled:n,onChange:s})=>{const c=x({title:"Checkout.BillToShippingAddress.title"});return r?t(y,{}):t("div",{className:"checkout-bill-to-shipping-address",children:t(b,{checked:e,className:B(["checkout-bill-to-shipping-address__checkbox",i]),"data-testid":"bill-to-shipping-checkbox",disabled:n,label:c.title,name:"checkout-bill-to-shipping-address__checkbox",onChange:s})})},y=()=>t(f,{className:"bill-to-shipping-address__skeleton",children:t(A,{variant:"row",size:"small"})}),k=({onChange:i})=>{var g;const[e,r]=v(!0),n=d.value,s=u.value.data,c=u.value.pending,p=!!s,m=!!(s==null?void 0:s.billingAddress),l=(g=s==null?void 0:s.shippingAddresses)==null?void 0:g[0],h=l==null?void 0:l.sameAsBilling;return _(()=>{if(!e||!p)return;r(!1);const o=h??!m;d.value=o,i==null||i(o)},[p,m,h,e,i]),t(w,{checked:n,disabled:c,loading:e,onChange:async o=>{const a=o.target.checked;d.value=a,i==null||i(a),!e&&l&&a&&await S({sameAsShipping:!0}).catch(console.error)}})};k.displayName="BillToShippingAddressContainer";const V=T(k);export{V as BillToShippingAddress,V as default};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AlertBannerProps } from '@dropins/tools/types/elsie/src/components';
|
|
2
2
|
|
|
3
3
|
export declare const MergedCartBanner: {
|
|
4
|
-
({ hideOnEmptyCart, hideOnVirtualCart, ...props }: import('../../hocs').ConditionalProps & AlertBannerProps): import("preact
|
|
4
|
+
({ hideOnEmptyCart, hideOnVirtualCart, ...props }: import('../../hocs').ConditionalProps & AlertBannerProps): import("preact").JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=MergedCartBanner.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as e}from"@dropins/tools/preact-jsx-runtime.js";import{AlertBanner as g,Icon as u}from"@dropins/tools/components.js";import{c as h}from"../chunks/classes.js";import{events as B}from"@dropins/tools/event-bus.js";import
|
|
3
|
+
import{jsx as e}from"@dropins/tools/preact-jsx-runtime.js";import{AlertBanner as g,Icon as u}from"@dropins/tools/components.js";import{c as h}from"../chunks/classes.js";import{events as B}from"@dropins/tools/event-bus.js";import{useState as I,useEffect as M}from"@dropins/tools/preact-hooks.js";import{w as v}from"../chunks/withConditionalRendering.js";import*as l from"@dropins/tools/preact-compat.js";import{useText as w,Text as x}from"@dropins/tools/i18n.js";import"../chunks/transform-store-config.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/store-config.js";import"../chunks/state.js";import"@dropins/tools/signals.js";import"@dropins/tools/lib.js";const H=t=>l.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 12C0 5.37931 5.37931 0 12 0C18.6207 0 24 5.37931 24 12C24 18.6207 18.6207 24 12 24C5.37931 24 0 18.6207 0 12ZM11.8885 5.06101C11.1405 5.06101 10.5357 5.66579 10.5357 6.4138V6.57295C10.5835 7.27321 11.1882 7.81433 11.8885 7.76658H12.0795C12.7797 7.70292 13.289 7.09815 13.2413 6.4138C13.2413 5.66579 12.6365 5.06101 11.8885 5.06101ZM13.1935 16.8223H14.1007C14.2599 16.8223 14.4031 16.9655 14.4031 17.1247V17.7294C14.4031 17.9045 14.2599 18.0318 14.1007 18.0318H9.8832C9.70813 18.0318 9.58081 17.8886 9.58081 17.7294V17.1247C9.58081 16.9496 9.72405 16.8223 9.8832 16.8223H10.7904V10.7905H9.8832C9.70813 10.7905 9.58081 10.6472 9.58081 10.4881V9.88329C9.58081 9.70823 9.72405 9.58091 9.8832 9.58091H12.5888C12.923 9.58091 13.1935 9.85146 13.1935 10.1857V16.8223Z",fill:"currentColor"})),C=({className:t,initialData:V,...c})=>{const[r,a]=I(0),i=w({mergedCartBannerItems:e(x,{id:"Checkout.MergedCartBanner.items",fields:{count:r},plural:r})});M(()=>{const n=B.on("cart/merged",o=>{var m;const s=(m=o==null?void 0:o.oldCartItems)==null?void 0:m.reduce((f,p)=>f+p.quantity,0);s>0&&a(s)});return()=>{n==null||n.off()}},[]);const d=()=>{a(0)};return r?e(g,{...c,"aria-label":i.mergedCartBannerItems,className:h(["checkout__banner",t]),"data-testid":"merged-cart-banner",icon:e(u,{source:H}),message:e("span",{children:i.mergedCartBannerItems}),onDismiss:d,variant:"neutral"}):null};C.displayName="MergedCartBannerContainer";const A=v(C);export{A as MergedCartBanner,A 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 e}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Card as k,Icon as l,Image as h}from"@dropins/tools/components.js";import"../chunks/TermsAndConditions.js";import{classes as O}from"@dropins/tools/lib.js";import{S as d}from"../chunks/OrderError.js";import{useText as p}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{events as S}from"@dropins/tools/event-bus.js";import{useState as v,useCallback as _,useEffect as g}from"@dropins/tools/preact-compat.js";const N=({className:i,items:r,onRemoveOutOfStock:o,routeCart:a,...m})=>{const s=p({title:"Checkout.OutOfStock.title",message:"Checkout.OutOfStock.message",reviewCart:"Checkout.OutOfStock.actions.reviewCart",removeOutOfStock:"Checkout.OutOfStock.actions.removeOutOfStock"});return n(k,{className:O(["checkout-out-of-stock",i]),"data-testid":"checkout-out-of-stock",variant:"secondary",...m,children:[n("h4",{className:"checkout-out-of-stock__title",children:[e(l,{source:d,size:"16",stroke:"1"}),s.title]}),e("p",{className:"checkout-out-of-stock__message",children:s.message}),e("ol",{className:"checkout-out-of-stock__items",children:r.map(u=>e("li",{"data-testid":"out-of-stock-item",className:"checkout-out-of-stock__item",children:e(h,{loading:"eager",src:u.image.src,alt:u.image.alt,width:"100",height:"100",params:{width:100}})},u.sku))}),n("div",{className:"checkout-out-of-stock__actions",children:[a&&e("a",{"data-testid":"review-cart",className:"checkout-out-of-stock__action",href:a,children:s.reviewCart}),o&&e("button",{className:"checkout-out-of-stock__action","data-testid":"remove-out-of-stock",type:"button",onClick:o,children:s.removeOutOfStock})]})]})}
|
|
3
|
+
import{jsxs as n,jsx as e}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Card as k,Icon as l,Image as h}from"@dropins/tools/components.js";import"../chunks/TermsAndConditions.js";import{classes as O}from"@dropins/tools/lib.js";import{S as d}from"../chunks/OrderError.js";import{useText as p}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{events as S}from"@dropins/tools/event-bus.js";import{useState as v,useCallback as _,useEffect as g}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";const N=({className:i,items:r,onRemoveOutOfStock:o,routeCart:a,...m})=>{const s=p({title:"Checkout.OutOfStock.title",message:"Checkout.OutOfStock.message",reviewCart:"Checkout.OutOfStock.actions.reviewCart",removeOutOfStock:"Checkout.OutOfStock.actions.removeOutOfStock"});return n(k,{className:O(["checkout-out-of-stock",i]),"data-testid":"checkout-out-of-stock",variant:"secondary",...m,children:[n("h4",{className:"checkout-out-of-stock__title",children:[e(l,{source:d,size:"16",stroke:"1"}),s.title]}),e("p",{className:"checkout-out-of-stock__message",children:s.message}),e("ol",{className:"checkout-out-of-stock__items",children:r.map(u=>e("li",{"data-testid":"out-of-stock-item",className:"checkout-out-of-stock__item",children:e(h,{loading:"eager",src:u.image.src,alt:u.image.alt,width:"100",height:"100",params:{width:100}})},u.sku))}),n("div",{className:"checkout-out-of-stock__actions",children:[a&&e("a",{"data-testid":"review-cart",className:"checkout-out-of-stock__action",href:a,children:s.reviewCart}),o&&e("button",{className:"checkout-out-of-stock__action","data-testid":"remove-out-of-stock",type:"button",onClick:o,children:s.removeOutOfStock})]})]})},$=({onCartProductsUpdate:i,routeCart:r})=>{const[o,a]=v([]),m=t=>t.outOfStock||t.insufficientQuantity,s=_(()=>{if(!i)return;const t=o.filter(c=>c.outOfStock).map(c=>({uid:c.uid,quantity:0}));i(t)},[o,i]);if(g(()=>{const t=S.on("cart/data",c=>{const f=(c==null?void 0:c.items)||[];a(f.filter(m))},{eager:!0});return()=>{t==null||t.off()}},[]),o.length===0)return null;const u=!o.some(t=>t.insufficientQuantity);return e(N,{items:o,onRemoveOutOfStock:u?s:void 0,routeCart:r==null?void 0:r()})};export{$ as OutOfStock,$ as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as n,jsxs as w}from"@dropins/tools/preact-jsx-runtime.js";import{s as z}from"../chunks/state.js";import{c as M,d as m}from"../chunks/transform-store-config.js";import"@dropins/tools/event-bus.js";import{classes as P,Slot as I}from"@dropins/tools/lib.js";import{s as R}from"../chunks/setPaymentMethod.js";/* empty css */import{IllustratedMessage as B,Icon as N,ProgressSpinner as U,ToggleButton as Z,Skeleton as D,SkeletonRow as f}from"@dropins/tools/components.js";import*as y from"@dropins/tools/preact-compat.js";import{
|
|
3
|
+
import{jsx as n,jsxs as w}from"@dropins/tools/preact-jsx-runtime.js";import{s as z}from"../chunks/state.js";import{c as M,d as m}from"../chunks/transform-store-config.js";import"@dropins/tools/event-bus.js";import{classes as P,Slot as I}from"@dropins/tools/lib.js";import{s as R}from"../chunks/setPaymentMethod.js";/* empty css */import{IllustratedMessage as B,Icon as N,ProgressSpinner as U,ToggleButton as Z,Skeleton as D,SkeletonRow as f}from"@dropins/tools/components.js";import*as y from"@dropins/tools/preact-compat.js";import{useText as $}from"@dropins/tools/i18n.js";import{w as q}from"../chunks/withConditionalRendering.js";import{useRef as F,useState as G,useEffect as L,useCallback as J}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/store-config.js";import"@dropins/tools/signals.js";import"../chunks/errors.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const K=e=>y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},y.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"}),y.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),y.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),Q=({code:e,loading:c,selected:s,onChange:r,title:a,icon:o})=>n(Z,{className:"checkout-payment-methods__method",label:a,name:"payment-method",value:e,selected:s,onChange:r,busy:c,icon:o?n(N,{source:o}):void 0}),X=({className:e,paymentMethodContent:c,loading:s=!1,initializing:r=!1,onChange:a=()=>{},options:o,selection:v})=>{const u=$({Title:"Checkout.PaymentMethods.title",EmptyState:"Checkout.PaymentMethods.emptyState"});return r?n(Y,{}):w("div",{className:P(["checkout-payment-methods",e]),children:[n("h2",{className:"checkout-payment-methods__title",children:u.Title}),!s&&o.length===0&&n(B,{icon:n(N,{source:K}),message:n("p",{children:u.EmptyState})}),w("div",{className:P(["checkout-payment-methods__wrapper",["checkout-payment-methods__wrapper--loading",s]]),children:[s&&n(U,{className:"checkout-payment-methods__spinner"}),n("div",{className:P(["checkout-payment-methods__methods",["checkout-payment-methods--full-width",o.length%2!==0]]),children:o==null?void 0:o.map(d=>n(Q,{code:d.code,onChange:a,selected:d.code===v,title:d.displayLabel??!0?d.title:"",icon:d.icon},d.code))}),c&&n("div",{className:"checkout-payment-methods__content",children:c})]})]})},Y=()=>w(D,{"data-testid":"payment-methods-skeleton",children:[n(f,{variant:"heading",size:"medium"}),n(f,{variant:"empty",size:"medium"}),n(f,{size:"xlarge",fullWidth:!0}),n(f,{size:"xlarge",fullWidth:!0})]}),ee=(e,c)=>{const s=F(e);return c(s.current,e)||(s.current=e),s.current},O=({slots:e,setOnChange:c={}})=>{var b,_,H,E,x;const[s]=G(c),r=e==null?void 0:e.Methods;L(()=>{e!=null&&e.Handlers&&console.warn("The `slots.Handlers` prop is deprecated and will be removed in future versions. Use the `Methods` object instead."),c&&console.warn("The `setOnChange` prop is deprecated and will be removed in future versions. Use the `Methods` object instead.")},[]);const a=M.value.data,o=!!M.value.data,v=M.value.pending,u=(a==null?void 0:a.isVirtual)??!1,d=(b=a==null?void 0:a.shippingAddresses)==null?void 0:b[0],V=(a==null?void 0:a.availablePaymentMethods)||[],p=(_=a==null?void 0:a.selectedPaymentMethod)==null?void 0:_.code,S=u?!0:!!d,l=ee(V.filter(t=>{var i;return((i=r==null?void 0:r[t.code])==null?void 0:i.enabled)!==!1}),(t,i)=>t.length!==i.length?!1:t.every((h,C)=>h.code===i[C].code)),g=J(t=>{var i;m.value=t,!(!t||!S)&&t!==p&&(s[t]===!1||((i=r==null?void 0:r[t])==null?void 0:i.setOnChange)===!1||R({code:t}).catch(console.error))},[S,r,p,s]);L(()=>{if(!o||!!!(l!=null&&l.length))return;const i=l[0].code,h=p||m.value,C=h?l.some(W=>W.code===h):!1;g(C?h:i)},[l,o,g,p]);const j=t=>{g(t)},k=m.value?((E=(H=e==null?void 0:e.Methods)==null?void 0:H[m.value])==null?void 0:E.render)||((x=e==null?void 0:e.Handlers)==null?void 0:x[m.value]):null,A=k?n(I,{name:"PaymentMethodContent",slot:k,context:{cartId:z.cartId||"",replaceHTML(t){this.replaceWith(t)}}},k):void 0,T=l.map(t=>{const i=(r==null?void 0:r[t.code])||{};return{...t,...i}});return n(X,{initializing:o===!1,loading:o&&v,onChange:j,options:T,paymentMethodContent:A,selection:m.value})};O.displayName="PaymentMethodsContainer";const ge=q(O);export{ge as PaymentMethods,ge as default};
|
package/containers/PlaceOrder.js
CHANGED
|
@@ -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";/* empty css */import{Button as E}from"@dropins/tools/components.js";import{classes as S,Slot as P}from"@dropins/tools/lib.js";import{w as y}from"../chunks/withConditionalRendering.js";import{s as b}from"../chunks/state.js";import{c as U,b as I,a as w,d}from"../chunks/transform-store-config.js";import{U as N}from"../chunks/errors.js";import{events as T}from"@dropins/tools/event-bus.js";import{useState as z,useCallback as l,useEffect as D}from"@dropins/tools/preact-
|
|
3
|
+
import{jsx as a}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Button as E}from"@dropins/tools/components.js";import{classes as S,Slot as P}from"@dropins/tools/lib.js";import{w as y}from"../chunks/withConditionalRendering.js";import{s as b}from"../chunks/state.js";import{c as U,b as I,a as w,d}from"../chunks/transform-store-config.js";import{U as N}from"../chunks/errors.js";import{events as T}from"@dropins/tools/event-bus.js";import{useState as z,useCallback as l,useEffect as D}from"@dropins/tools/preact-hooks.js";import{useText as H,Text as _}from"@dropins/tools/i18n.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/store-config.js";import"@dropins/tools/signals.js";const j=({children:t,className:o,disabled:n=!1,onClick:r})=>a("div",{className:S(["checkout-place-order",o]),children:a(E,{className:"checkout-place-order__button","data-testid":"place-order-button",disabled:n,onClick:r,size:"medium",type:"submit",variant:"primary",children:t},"placeOrder")}),B=t=>t instanceof TypeError||t instanceof N,u=({disabled:t=!1,handleValidation:o,handlePlaceOrder:n,slots:r,...p})=>{const[f,C]=z(!1),{data:O,pending:k}=U.value,g=I.value.pending,h=!!O,s=H({CheckoutUnexpectedError:"Checkout.ServerError.unexpected"}),i=l(e=>{w.value=B(e)?s.CheckoutUnexpectedError:e.message},[s]),v=l(async()=>{try{if(!(o?o():!0))return;await n({cartId:b.cartId||"",code:d.value||""})}catch(e){i(e)}},[o,n,i]);return D(()=>{const e=T.on("cart/initialized",c=>{const x=(c==null?void 0:c.items)||[];C(x.some(m=>m.outOfStock||m.insufficientQuantity))},{eager:!0});return()=>{e==null||e.off()}},[]),a(j,{...p,onClick:v,disabled:t||!h||k||f||g,children:r!=null&&r.Content?a(P,{name:"Content",slot:r.Content,context:{code:d.value||""}}):a(_,{id:"Checkout.PlaceOrder.button"})})};u.displayName="PlaceOrderContainer";const Z=y(u);export{Z as PlaceOrder,Z as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as n,jsxs as g,Fragment as b}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/state.js";import{c as S,e as w,s as C}from"../chunks/transform-store-config.js";import{events as H}from"@dropins/tools/event-bus.js";import{classes as E,Slot as z}from"@dropins/tools/lib.js";import{t as R,s as T}from"../chunks/setShippingMethods.js";/* empty css */import{IllustratedMessage as O,Icon as P,ProgressSpinner as B,RadioButton as D,Price as I,Skeleton as V,SkeletonRow as f}from"@dropins/tools/components.js";import*as r from"@dropins/tools/preact-compat.js";import{
|
|
3
|
+
import{jsx as n,jsxs as g,Fragment as b}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/state.js";import{c as S,e as w,s as C}from"../chunks/transform-store-config.js";import{events as H}from"@dropins/tools/event-bus.js";import{classes as E,Slot as z}from"@dropins/tools/lib.js";import{t as R,s as T}from"../chunks/setShippingMethods.js";/* empty css */import{IllustratedMessage as O,Icon as P,ProgressSpinner as B,RadioButton as D,Price as I,Skeleton as V,SkeletonRow as f}from"@dropins/tools/components.js";import*as r from"@dropins/tools/preact-compat.js";import{useText as Z}from"@dropins/tools/i18n.js";import{w as q}from"../chunks/withConditionalRendering.js";import{useCallback as F,useMemo as $,useEffect as A}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/store-config.js";import"@dropins/tools/signals.js";import"../chunks/errors.js";import"../chunks/synchronizeCheckout.js";import"../fragments.js";const G=e=>r.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.47266 4.90002H15.1851V10.9645H21.2495L23 12.715V17.6124H20.073",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76151 16.7898C9.76151 18.0525 8.72845 19.076 7.46582 19.076C6.20318 19.076 5.17969 18.0429 5.17969 16.7803C5.17969 15.5176 6.20318 14.4941 7.46582 14.4941C8.72845 14.4941 9.75195 15.5176 9.76151 16.7803C9.76151 16.7803 9.76151 16.7803 9.76151 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8726 16.7898C19.8726 18.062 18.8491 19.0855 17.5769 19.0855C16.3047 19.0855 15.2812 18.062 15.2812 16.7898C15.2812 15.5176 16.3047 14.4941 17.5769 14.4941C18.8491 14.4941 19.8726 15.5176 19.8726 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),r.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),J=({className:e,isLoading:t=!1,onSelectionChange:s=()=>{},options:d,selection:u,...h})=>{const i=Z({Title:"Checkout.ShippingMethods.title",EmptyState:"Checkout.ShippingMethods.emptyState"});return d===void 0?n(K,{}):g("div",{...h,className:E(["checkout-shipping-methods",e]),children:[n("h3",{className:"checkout-shipping-methods__title",children:i.Title}),!t&&d.length===0&&n(O,{icon:n(P,{source:G}),message:n("p",{children:i.EmptyState})}),g("div",{className:E(["checkout-shipping-methods__content"]),children:[t&&n(B,{className:"checkout-shipping-methods__spinner"}),n("div",{className:E(["checkout-shipping-methods__options",["checkout-shipping-methods__options--loading",t]]),children:d.map(o=>n(D,{"data-testid":"shipping-method-radiobutton","aria-busy":t,id:o.value,name:"shipping-method",className:"checkout-shipping-methods__method",label:g(b,{children:[n(I,{amount:o.amount.value,currency:o.amount.currency})," ",n("span",{children:o.carrier.title})]}),description:o.title,value:o.value,checked:(u==null?void 0:u.value)===o.value,onChange:()=>s(o)},o.value))})]})]})},K=()=>g(V,{"data-testid":"shipping-methods-skeleton",children:[n(f,{variant:"heading",size:"small"}),n(f,{variant:"empty",size:"small"}),n(f,{size:"medium",fullWidth:!0}),n(f,{size:"medium",fullWidth:!0})]}),L=(e,t)=>e.code===t.code&&e.carrier.code===t.carrier.code;function Q(e){const t=H.lastPayload("shipping/estimate");if(!(t!=null&&t.address))return;const s={address:t.address,shippingMethod:R(e)};H.emit("shipping/estimate",s)}function U({preSelectedMethod:e,onShippingMethodSelect:t}){const s=S.value.data,d=S.value.pending,u=w.value.data,h=w.value.pending,i=C.value,o=s==null?void 0:s.shippingAddresses,a=o==null?void 0:o[0],v=!!a,N=a==null?void 0:a.availableShippingMethods,m=a==null?void 0:a.selectedShippingMethod,l=N||u,_=F(c=>{if(!v)return;const k={method_code:c.code,carrier_code:c.carrier.code};T([k]).catch(j=>{console.error("Setting shipping methods on cart failed:",j)})},[v]),x=c=>{C.value=c,t==null||t(c),v||Q(c)},p=$(()=>{if(!(l!=null&&l.length))return;const c=l[0],k=i||m;return k?l.some(M=>L(M,k))?k:c:l.find(W=>W.carrier.code===(e==null?void 0:e.carrierCode)&&W.code===(e==null?void 0:e.methodCode))||c},[i,m,l,e]);return A(()=>{p&&((!i||!L(p,i))&&(C.value=p,t==null||t(p)),(!m||!L(p,m))&&_(p))},[p,i,m,_,t]),{isLoading:d||h,options:l,selection:p,onSelectionChange:x}}const y=({preSelectedMethod:e,shippingMethodsSlot:t,onShippingMethodSelect:s,initialData:d,...u})=>{const{isLoading:h,options:i,selection:o,onSelectionChange:a}=U({preSelectedMethod:e,onShippingMethodSelect:s});return g(b,{children:[n(J,{...u,isLoading:h,onSelectionChange:a,options:i,selection:o}),!h&&t&&n(z,{name:"ShippingMethods",slot:t})]})};y.displayName="ShippingMethodsContainer";const kt=q(y);export{kt as ShippingMethods,kt as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as e,jsxs as E}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Skeleton as N,SkeletonRow as w,Checkbox as j}from"@dropins/tools/components.js";import{p as y}from"../chunks/TermsAndConditions.js";import{classes as
|
|
3
|
+
import{jsx as e,jsxs as E}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Skeleton as N,SkeletonRow as w,Checkbox as j}from"@dropins/tools/components.js";import{p as y}from"../chunks/TermsAndConditions.js";import{classes as k,VComponent as D,Slot as H}from"@dropins/tools/lib.js";/* empty css *//* empty css *//* empty css */import{A as P}from"../chunks/checkout.js";import{events as p}from"@dropins/tools/event-bus.js";import{s as R}from"../chunks/state.js";import{useState as i,useCallback as g,useEffect as A}from"@dropins/tools/preact-hooks.js";import{useText as V,MarkupText as $}from"@dropins/tools/i18n.js";const q=({html:n})=>{const r=y.sanitize(n,{ADD_ATTR:["target"]});return r===""?null:e("span",{dangerouslySetInnerHTML:{__html:r}})},L=({className:n,agreements:r,error:s,isInitialized:a=!1,...c})=>a?e("div",{className:"checkout-terms-and-conditions","data-testid":"checkout-terms-and-conditions",children:E("form",{...c,className:k(["checkout-terms-and-conditions__form",n]),name:"checkout-terms-and-conditions__form","data-testid":"checkout-terms-and-conditions-form",noValidate:!0,children:[r&&e(D,{node:r,className:k(["checkout-terms-and-conditions__agreements"]),"data-testid":"checkout-terms-and-conditions-agreements"}),s&&e("div",{className:"checkout-terms-and-conditions__error","data-testid":"checkout-terms-and-conditions-error",children:s})]})}):e(O,{}),O=()=>e(N,{"data-testid":"checkout-terms-and-conditions-skeleton",className:"checkout-terms-and-conditions-skeleton",children:e(w,{variant:"row",size:"small",fullWidth:!0})}),ne=({slots:n,...r})=>{const[s,a]=i(!0),[c,_]=i(!1),[C,T]=i(!1),[x,m]=i(""),{errorMessage:l}=V({errorMessage:"Checkout.TermsAndConditions.error"}),I=g(()=>{m("")},[]),v=g(()=>{m(l)},[l]);return A(()=>{const t=p.on("checkout/initialized",()=>{var o;_(!0),a(((o=R.config)==null?void 0:o.isCheckoutAgreementsEnabled)??!0)},{eager:!0});return()=>{t==null||t.off()}},[]),A(()=>{const t=p.on("authenticated",o=>{T(o)},{eager:!0});return()=>{t==null||t.off()}},[]),!s||C?null:e(L,{...r,error:x,isInitialized:c,agreements:e(H,{name:"Agreements",slot:n==null?void 0:n.Agreements,context:{appendAgreement(t){this._registerMethod((...o)=>{const u=t(...o);if(!u)return;const{mode:M,name:h,text:d,translationId:f}=u;if(!d&&!f){console.warn(`The agreement ${h} is misconfigured. Please provide a text or a translationId.`);return}const b=d?e(q,{html:d}):e($,{id:f}),S=e(j,{checked:M===P.AUTO,label:b,name:h,required:!0,onChange:I,onInvalid:v});this._setProps(z=>({children:[...z.children||[],S]}))})}}})})};export{ne as TermsAndConditions,ne as default};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-checkout", "version": "1.3.0
|
|
1
|
+
{"name": "@dropins/storefront-checkout", "version": "1.3.0", "@dropins/tools": "~0.41.0", "license": "SEE LICENSE IN LICENSE.md"}
|