@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
|
|
4
|
-
|
|
5
|
-
handleValidation?: () => boolean;
|
|
6
|
-
handlePlaceOrder: (ctx: PlaceOrderContext) => Promise<void>;
|
|
4
|
+
export interface ContentSlotContext {
|
|
5
|
+
code: string;
|
|
7
6
|
}
|
|
8
|
-
export interface
|
|
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;
|
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
|
|
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
|
+
{"name": "@dropins/storefront-checkout", "version": "1.2.0", "@dropins/tools": "~0.40.0", "license": "SEE LICENSE IN LICENSE.md"}
|