@dropins/storefront-checkout 1.1.0 → 1.2.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.
@@ -1,14 +1,21 @@
1
+ import { SlotProps } from '@dropins/tools/types/elsie/src/lib';
1
2
  import { HTMLAttributes } from 'preact/compat';
2
3
 
3
- export interface PlaceOrderProps extends HTMLAttributes<HTMLDivElement> {
4
- disabled?: boolean;
5
- handleValidation?: () => boolean;
6
- handlePlaceOrder: (ctx: PlaceOrderContext) => Promise<void>;
4
+ export interface ContentSlotContext {
5
+ code: string;
7
6
  }
8
- export interface PlaceOrderContext {
7
+ export interface HandlePlaceOrderContext {
9
8
  code: string;
10
9
  cartId: string;
11
10
  }
11
+ export interface PlaceOrderProps extends HTMLAttributes<HTMLDivElement> {
12
+ disabled?: boolean;
13
+ handleValidation?: () => boolean;
14
+ handlePlaceOrder: (ctx: HandlePlaceOrderContext) => Promise<void>;
15
+ slots?: {
16
+ Content?: SlotProps<ContentSlotContext>;
17
+ };
18
+ }
12
19
  export declare const PlaceOrder: {
13
20
  ({ hideOnEmptyCart, hideOnVirtualCart, ...props }: import('../../hocs/withConditionalRendering').ConditionalProps & PlaceOrderProps): import("preact/compat").JSX.Element;
14
21
  displayName: string;
@@ -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 x}from"@dropins/tools/components.js";import{classes as E}from"@dropins/tools/lib.js";import{Text as g,useText as v}from"@dropins/tools/i18n.js";import{w as y}from"../chunks/withConditionalRendering.js";import{s as P}from"../chunks/store-config.js";import{c as S,a as b,b as U}from"../chunks/transform-store-config.js";import{U as I}from"../chunks/errors.js";import{events as w}from"@dropins/tools/event-bus.js";import{useState as N,useCallback as m,useEffect as T}from"@dropins/tools/preact-compat.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const z=r=>r instanceof TypeError||r instanceof I,D=({className:r,disabled:t=!1,onClick:o})=>a("div",{className:E(["checkout-place-order",r]),children:a(x,{className:"checkout-place-order__button","data-testid":"place-order-button",disabled:t,onClick:o,size:"medium",type:"submit",variant:"primary",children:a(g,{id:"Checkout.PlaceOrder.button"})},"placeOrder")}),l=({disabled:r=!1,handleValidation:t,handlePlaceOrder:o,...u})=>{const[d,p]=N(!1),{data:f,pending:O}=S.value,k=!!f,s=v({CheckoutUnexpectedError:"Checkout.ServerError.unexpected"}),n=m(e=>{b.value=z(e)?s.CheckoutUnexpectedError:e.message},[s]),h=m(async()=>{try{if(!(t?t():!0))return;await o({cartId:P.cartId||"",code:U.value||""})}catch(e){n(e)}},[t,o,n]);return T(()=>{const e=w.on("cart/initialized",c=>{const C=(c==null?void 0:c.items)||[];p(C.some(i=>i.outOfStock||i.insufficientQuantity))},{eager:!0});return()=>{e==null||e.off()}},[]),a(D,{...u,onClick:h,disabled:r||!k||O||d})};l.displayName="PlaceOrderContainer";const J=y(l);export{J as PlaceOrder,J as default};
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 g}from"@dropins/tools/lib.js";import{w as y}from"../chunks/withConditionalRendering.js";import{s as P}from"../chunks/store-config.js";import{c as b,a as U,b as u}from"../chunks/transform-store-config.js";import{U as I}from"../chunks/errors.js";import{events as w}from"@dropins/tools/event-bus.js";import{useState as N,useCallback as d,useEffect as T}from"@dropins/tools/preact-compat.js";import{useText as z,Text as D}from"@dropins/tools/i18n.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const H=t=>t instanceof TypeError||t instanceof I,_=({children:t,className:o,disabled:c=!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:c,onClick:r,size:"medium",type:"submit",variant:"primary",children:t},"placeOrder")}),l=({disabled:t=!1,handleValidation:o,handlePlaceOrder:c,slots:r,...p})=>{const[f,C]=N(!1),{data:O,pending:k}=b.value,h=!!O,s=z({CheckoutUnexpectedError:"Checkout.ServerError.unexpected"}),i=d(e=>{U.value=H(e)?s.CheckoutUnexpectedError:e.message},[s]),x=d(async()=>{try{if(!(o?o():!0))return;await c({cartId:P.cartId||"",code:u.value||""})}catch(e){i(e)}},[o,c,i]);return T(()=>{const e=w.on("cart/initialized",n=>{const v=(n==null?void 0:n.items)||[];C(v.some(m=>m.outOfStock||m.insufficientQuantity))},{eager:!0});return()=>{e==null||e.off()}},[]),a(_,{...p,onClick:x,disabled:t||!h||k||f,children:r!=null&&r.Content?a(g,{name:"Content",slot:r.Content,context:{code:u.value||""}}):a(D,{id:"Checkout.PlaceOrder.button"})})};l.displayName="PlaceOrderContainer";const W=y(l);export{W as PlaceOrder,W as default};
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-checkout", "version": "1.1.0", "@dropins/tools": "~0.39.0", "license": "SEE LICENSE IN LICENSE.md"}
1
+ {"name": "@dropins/storefront-checkout", "version": "1.2.0", "@dropins/tools": "~0.40.0", "license": "SEE LICENSE IN LICENSE.md"}