@vtex/faststore 0.0.8 → 0.0.10
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/CHANGELOG.md +59 -0
- package/dist/actions.json +42 -0
- package/dist/catalog.json +731 -16
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/components.d.ts +9 -4
- package/dist/components.js +11 -6
- package/dist/content-types.json +300 -0
- package/dist/core/dist/define-component.d.ts +6 -1
- package/dist/docs/account-entry-point.md +4 -4
- package/dist/docs/account-menu.md +2 -2
- package/dist/docs/account-saved-cards.md +301 -0
- package/dist/docs/binding-switcher.md +154 -0
- package/dist/docs/card-entry.md +3 -3
- package/dist/docs/card-summary.md +175 -0
- package/dist/docs/cart-destination.md +238 -0
- package/dist/docs/cart-item.md +21 -3
- package/dist/docs/cart-totalizer.md +1 -1
- package/dist/docs/cart.md +118 -11
- package/dist/docs/footer-social.md +1 -1
- package/dist/docs/free-shipping-progress.md +13 -9
- package/dist/docs/incentives.md +2 -2
- package/dist/docs/logo.md +1 -1
- package/dist/docs/payment-method-badges.md +2 -2
- package/dist/docs/payment-methods.md +1 -1
- package/dist/docs/product-information.md +2 -2
- package/dist/docs/product-shelf.md +7 -0
- package/dist/docs/select.md +3 -4
- package/dist/docs/sign-in-redirect.md +1 -1
- package/dist/docs/toast.md +30 -12
- package/dist/index.d.ts +2 -1
- package/dist/internal/client.d.ts +4 -1
- package/dist/internal/client.js +4 -1
- package/dist/internal/server.d.ts +4 -2
- package/dist/internal/server.js +4 -2
- package/dist/matter/account-saved-cards/account-saved-cards.d.ts +383 -0
- package/dist/matter/account-saved-cards/account-saved-cards.js +956 -0
- package/dist/matter/account-saved-cards/account-saved-cards.js.map +1 -0
- package/dist/matter/billing-address/billing-address.js.map +1 -1
- package/dist/matter/cart/cart-namespace.d.ts +5 -1
- package/dist/matter/cart/cart-namespace.js +5 -1
- package/dist/matter/cart/cart-namespace.js.map +1 -1
- package/dist/matter/cart/cart.d.ts +34 -4
- package/dist/matter/cart/cart.js +238 -28
- package/dist/matter/cart/cart.js.map +1 -1
- package/dist/matter/cart-destination/cart-destination.d.ts +222 -0
- package/dist/matter/cart-destination/cart-destination.js +613 -0
- package/dist/matter/cart-destination/cart-destination.js.map +1 -0
- package/dist/matter/cart-item/cart-item.d.ts +4 -2
- package/dist/matter/cart-item/cart-item.js +75 -16
- package/dist/matter/cart-item/cart-item.js.map +1 -1
- package/dist/matter/cart-totalizer/cart-totalizer.js +3 -2
- package/dist/matter/cart-totalizer/cart-totalizer.js.map +1 -1
- package/dist/matter/free-shipping-progress/free-shipping-progress.d.ts +6 -3
- package/dist/matter/free-shipping-progress/free-shipping-progress.js +76 -33
- package/dist/matter/free-shipping-progress/free-shipping-progress.js.map +1 -1
- package/dist/matter/pricing/pricing.js.map +1 -1
- package/dist/matter/product-shelf/product-shelf.d.ts +7 -0
- package/dist/matter/product-shelf/product-shelf.js +115 -1
- package/dist/matter/product-shelf/product-shelf.js.map +1 -1
- package/dist/matter/shipping-address/shipping-address.js.map +1 -1
- package/dist/matter/shipping-simulator/shipping-simulator.d.ts +1 -1
- package/dist/matter/shipping-simulator/shipping-simulator.js +6 -2
- package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
- package/dist/particles/binding-switcher/binding-switcher.d.ts +38 -0
- package/dist/particles/binding-switcher/binding-switcher.js +183 -0
- package/dist/particles/binding-switcher/binding-switcher.js.map +1 -0
- package/dist/particles/card-summary/card-network.d.ts +17 -0
- package/dist/particles/card-summary/card-network.js +25 -0
- package/dist/particles/card-summary/card-network.js.map +1 -0
- package/dist/particles/card-summary/card-summary.d.ts +83 -0
- package/dist/particles/card-summary/card-summary.js +188 -0
- package/dist/particles/card-summary/card-summary.js.map +1 -0
- package/dist/particles/footer-social/footer-social.d.ts +1 -1
- package/dist/particles/footer-social/footer-social.js +1 -1
- package/dist/particles/footer-social/footer-social.js.map +1 -1
- package/dist/particles/incentives/incentives.d.ts +1 -1
- package/dist/particles/incentives/incentives.js +1 -1
- package/dist/particles/incentives/incentives.js.map +1 -1
- package/dist/particles/payment-methods/payment-methods.d.ts +1 -1
- package/dist/particles/payment-methods/payment-methods.js +1 -1
- package/dist/particles/payment-methods/payment-methods.js.map +1 -1
- package/dist/particles/toast/toast.d.ts +20 -6
- package/dist/particles/toast/toast.js +49 -7
- package/dist/particles/toast/toast.js.map +1 -1
- package/dist/schema.graphql +298 -34
- package/dist/sdk/actions/index.d.ts +3 -1
- package/dist/sdk/actions/index.js +3 -1
- package/dist/sdk/actions/locale-action-provider.d.ts +16 -0
- package/dist/sdk/actions/locale-action-provider.js +20 -0
- package/dist/sdk/actions/locale-action-provider.js.map +1 -0
- package/dist/sdk/actions/saved-card-action-provider.d.ts +12 -0
- package/dist/sdk/actions/saved-card-action-provider.js +16 -0
- package/dist/sdk/actions/saved-card-action-provider.js.map +1 -0
- package/dist/sdk/actions/types.d.ts +6 -2
- package/dist/sdk/cache/storefront-cache.js +2 -1
- package/dist/sdk/cache/storefront-cache.js.map +1 -1
- package/dist/sdk/cart/operations.d.ts +2 -1
- package/dist/sdk/cart/operations.js +55 -1
- package/dist/sdk/cart/operations.js.map +1 -1
- package/dist/sdk/cart/optimistic.d.ts +30 -7
- package/dist/sdk/cart/optimistic.js +78 -41
- package/dist/sdk/cart/optimistic.js.map +1 -1
- package/dist/sdk/cart/use-cart-actions.d.ts +7 -0
- package/dist/sdk/cart/use-cart-actions.js +61 -15
- package/dist/sdk/cart/use-cart-actions.js.map +1 -1
- package/dist/sdk/cart/use-cart-sync-sales-channel.js +70 -0
- package/dist/sdk/cart/use-cart-sync-sales-channel.js.map +1 -0
- package/dist/sdk/generated/gql.js +15 -11
- package/dist/sdk/generated/gql.js.map +1 -1
- package/dist/sdk/generated/graphql.d.ts +177 -46
- package/dist/sdk/generated/graphql.js +2314 -93
- package/dist/sdk/generated/graphql.js.map +1 -1
- package/dist/sdk/i18n/messages/en-US.js +19 -0
- package/dist/sdk/i18n/messages/en-US.json +19 -0
- package/dist/sdk/i18n/messages/en-US.json.d.ts +19 -0
- package/dist/sdk/i18n/messages/es-ES.js +19 -0
- package/dist/sdk/i18n/messages/es-ES.json +19 -0
- package/dist/sdk/i18n/messages/pt-BR.js +19 -0
- package/dist/sdk/i18n/messages/pt-BR.json +19 -0
- package/dist/sdk/i18n/provider.js +1 -1
- package/dist/sdk/i18n/provider.js.map +1 -1
- package/dist/sdk/locale/binding-switch-provider.d.ts +13 -0
- package/dist/sdk/locale/binding-switch-provider.js +20 -0
- package/dist/sdk/locale/binding-switch-provider.js.map +1 -0
- package/dist/sdk/locale/use-locale-actions.d.ts +16 -0
- package/dist/sdk/locale/use-locale-actions.js +70 -0
- package/dist/sdk/locale/use-locale-actions.js.map +1 -0
- package/dist/sdk/navigation/binding-switch.d.ts +39 -0
- package/dist/sdk/navigation/binding-switch.js +129 -0
- package/dist/sdk/navigation/binding-switch.js.map +1 -0
- package/dist/sdk/navigation/decode-route-params.d.ts +11 -0
- package/dist/sdk/navigation/decode-route-params.js +32 -0
- package/dist/sdk/navigation/decode-route-params.js.map +1 -0
- package/dist/sdk/saved-cards/operations.d.ts +16 -0
- package/dist/sdk/saved-cards/operations.js +41 -0
- package/dist/sdk/saved-cards/operations.js.map +1 -0
- package/dist/sdk/saved-cards/use-saved-card-actions.d.ts +26 -0
- package/dist/sdk/saved-cards/use-saved-card-actions.js +86 -0
- package/dist/sdk/saved-cards/use-saved-card-actions.js.map +1 -0
- package/dist/sdk/seo/page-alternates.d.ts +5 -3
- package/dist/sdk/seo/page-alternates.js +7 -12
- package/dist/sdk/seo/page-alternates.js.map +1 -1
- package/dist/sdk/shipping/shipping-operations.d.ts +1 -1
- package/dist/sdk/shipping/shipping-operations.js +13 -0
- package/dist/sdk/shipping/shipping-operations.js.map +1 -1
- package/dist/sdk/state/cart.d.ts +9 -2
- package/dist/sdk/state/cart.js +9 -2
- package/dist/sdk/state/cart.js.map +1 -1
- package/package.json +2 -2
- package/src/styles/tailwind.css +1 -2
|
@@ -59,6 +59,8 @@ export type CartRootProps = ComponentPropsWithRef<'div'> & {
|
|
|
59
59
|
* session, or `orderFormIdVar` is still null).
|
|
60
60
|
*/
|
|
61
61
|
$data?: CartEntity | null;
|
|
62
|
+
/** Injected by the compiler from `actions: { cart: ['syncSalesChannel'] }`. */
|
|
63
|
+
$actions?: ComponentActions;
|
|
62
64
|
};
|
|
63
65
|
export type CartListProps = ComponentPropsWithRef<'div'> & {
|
|
64
66
|
/** Number of CartItemSkeleton rows to render while the cart is still loading (FR-7). */
|
|
@@ -68,7 +70,10 @@ export type CartTotalProps = ComponentPropsWithRef<'span'> & {
|
|
|
68
70
|
label?: string;
|
|
69
71
|
};
|
|
70
72
|
export type CartCountProps = ComponentPropsWithRef<'span'> & {
|
|
73
|
+
/** Output format; `{count}` is replaced by the count. Used for every count without a `templateOne` match. */
|
|
71
74
|
template?: string;
|
|
75
|
+
/** Output format used only when the count is exactly 1; falls back to `template` when unset or blank. */
|
|
76
|
+
templateOne?: string;
|
|
72
77
|
};
|
|
73
78
|
export type CartErrorProps = ComponentPropsWithRef<'div'>;
|
|
74
79
|
export type CartGoCheckoutProps = Omit<NavigationLinkProps, 'href' | '$content'> & {
|
|
@@ -84,6 +89,8 @@ export type CartGoCheckoutProps = Omit<NavigationLinkProps, 'href' | '$content'>
|
|
|
84
89
|
export type CartCouponFormProps = ComponentPropsWithRef<'form'> & {
|
|
85
90
|
placeholder?: string;
|
|
86
91
|
applyLabel?: string;
|
|
92
|
+
/** Title of the toast raised after an apply whose code comes back matched; blank raises none. */
|
|
93
|
+
appliedMessage?: string;
|
|
87
94
|
/** Injected by the compiler from `actions: { cart: ['applyCoupon'] }`; the cart write surface. */
|
|
88
95
|
$actions?: ComponentActions;
|
|
89
96
|
};
|
|
@@ -101,6 +108,15 @@ export type CartCouponRemoveProps = ComponentPropsWithRef<'button'> & {
|
|
|
101
108
|
$actions?: ComponentActions;
|
|
102
109
|
};
|
|
103
110
|
export type CartCouponErrorProps = ComponentPropsWithRef<'div'>;
|
|
111
|
+
export type CartCouponEmptyProps = ComponentPropsWithRef<'div'>;
|
|
112
|
+
export type CartCouponUnmatchedProps = ComponentPropsWithRef<'output'> & {
|
|
113
|
+
/** Notice copy shown while the enclosing chip's coupon is unmatched; blank renders nothing. */
|
|
114
|
+
message?: string;
|
|
115
|
+
};
|
|
116
|
+
export type CartCouponSavingsProps = Omit<ComponentPropsWithRef<'span'>, 'children'> & {
|
|
117
|
+
/** Chip text; every `{amount}` is the formatted saving, every `{code}` the chip's code. Blank counts as unset. */
|
|
118
|
+
template?: string;
|
|
119
|
+
};
|
|
104
120
|
export type CartDisclaimerProps = ComponentPropsWithRef<'p'> & {
|
|
105
121
|
/**
|
|
106
122
|
* Authored fallback, rendered when no CMS entry supplies the notice. Ranks below `children`:
|
|
@@ -129,6 +145,12 @@ export type CartContinueShoppingProps = ComponentPropsWithRef<'button'> & {
|
|
|
129
145
|
export type CartUnavailableCountProps = ComponentPropsWithRef<'span'> & {
|
|
130
146
|
/** Output format; `{count}` is replaced by the integer count. */
|
|
131
147
|
template?: string;
|
|
148
|
+
/** Output format used only when exactly one line is unavailable; falls back to `template` when unset or blank. */
|
|
149
|
+
templateOne?: string;
|
|
150
|
+
};
|
|
151
|
+
export type ClearCartButtonProps = ComponentPropsWithRef<'button'> & {
|
|
152
|
+
/** Injected by the compiler from `actions: { cart: ['removeItems'] }`; the cart write surface. */
|
|
153
|
+
$actions?: ComponentActions;
|
|
132
154
|
};
|
|
133
155
|
export type CartRemoveUnavailableProps = ComponentPropsWithRef<'button'> & {
|
|
134
156
|
/** Injected by the compiler from `actions: { cart: ['removeItems'] }`; the cart write surface. */
|
|
@@ -163,25 +185,33 @@ export declare const CartCouponFormDefinition: ComponentDefinition<CartCouponFor
|
|
|
163
185
|
export declare const CartAppliedCouponsDefinition: ComponentDefinition<CartAppliedCouponsProps>;
|
|
164
186
|
export declare const CartCouponRemoveDefinition: ComponentDefinition<CartCouponRemoveProps>;
|
|
165
187
|
export declare const CartCouponErrorDefinition: ComponentDefinition<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
|
|
166
|
-
export declare
|
|
188
|
+
export declare const CartCouponEmptyDefinition: ComponentDefinition<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
|
|
189
|
+
export declare const CartCouponUnmatchedDefinition: ComponentDefinition<CartCouponUnmatchedProps>;
|
|
190
|
+
export declare const CartCouponSavingsDefinition: ComponentDefinition<CartCouponSavingsProps>;
|
|
191
|
+
export declare function CartRoot({ $data: $dataProp, $actions: $actionsProp, className, children, ...props }: CartRootProps): import("react/jsx-runtime").JSX.Element;
|
|
167
192
|
export declare function CartList({ className, children, skeletonCount, ...props }: CartListProps): import("react/jsx-runtime").JSX.Element;
|
|
168
193
|
export declare function CartTotal({ label, className, children, ...props }: CartTotalProps): import("react/jsx-runtime").JSX.Element;
|
|
169
|
-
export declare function CartCount({ className, children, template, ...props }: CartCountProps): import("react/jsx-runtime").JSX.Element;
|
|
194
|
+
export declare function CartCount({ className, children, template, templateOne, ...props }: CartCountProps): import("react/jsx-runtime").JSX.Element | null;
|
|
170
195
|
export declare function CartError({ className, children, ...props }: CartErrorProps): import("react/jsx-runtime").JSX.Element | null;
|
|
171
196
|
export declare function CartGoCheckout({ href, label, className, children, onClick, $content, $actions: $actionsProp, ...props }: CartGoCheckoutProps): import("react/jsx-runtime").JSX.Element;
|
|
172
|
-
export declare function CartCouponForm({ placeholder, applyLabel, className, children, onSubmit, $actions: $actionsProp, ...props }: CartCouponFormProps): import("react/jsx-runtime").JSX.Element;
|
|
197
|
+
export declare function CartCouponForm({ placeholder, applyLabel, appliedMessage, className, children, onSubmit, $actions: $actionsProp, ...props }: CartCouponFormProps): import("react/jsx-runtime").JSX.Element;
|
|
173
198
|
export declare function CartAppliedCoupons({ className, children, $actions: $actionsProp, ...props }: CartAppliedCouponsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
174
199
|
export declare function CartCouponRemove({ code, className, children, onClick, $actions: $actionsProp, ...props }: CartCouponRemoveProps): import("react/jsx-runtime").JSX.Element;
|
|
175
200
|
export declare function CartCouponError({ className, children, ...props }: CartCouponErrorProps): import("react/jsx-runtime").JSX.Element | null;
|
|
201
|
+
export declare function CartCouponEmpty({ className, children, ...props }: CartCouponEmptyProps): import("react/jsx-runtime").JSX.Element | null;
|
|
202
|
+
export declare function CartCouponUnmatched({ message, className, children, ...props }: CartCouponUnmatchedProps): import("react/jsx-runtime").JSX.Element | null;
|
|
203
|
+
export declare function CartCouponSavings({ className, template, ...props }: CartCouponSavingsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
176
204
|
export declare const CartCheckoutGuardDefinition: ComponentDefinition<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
|
|
177
205
|
export declare const CartLoadingDefinition: ComponentDefinition<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
|
|
178
206
|
export declare const CartEmptyDefinition: ComponentDefinition<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
|
|
179
207
|
export declare const CartFilledDefinition: ComponentDefinition<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
|
|
180
208
|
export declare const CartUnavailableCountDefinition: ComponentDefinition<CartUnavailableCountProps>;
|
|
181
209
|
export declare const CartRemoveUnavailableDefinition: ComponentDefinition<CartRemoveUnavailableProps>;
|
|
210
|
+
export declare const ClearCartButtonDefinition: ComponentDefinition<ClearCartButtonProps>;
|
|
182
211
|
export declare function CartCheckoutGuard({ className, children, ...props }: CartCheckoutGuardProps): import("react/jsx-runtime").JSX.Element;
|
|
183
|
-
export declare function CartUnavailableCount({ className, children, template, ...props }: CartUnavailableCountProps): import("react/jsx-runtime").JSX.Element | null;
|
|
212
|
+
export declare function CartUnavailableCount({ className, children, template, templateOne, ...props }: CartUnavailableCountProps): import("react/jsx-runtime").JSX.Element | null;
|
|
184
213
|
export declare function CartRemoveUnavailable({ className, children, onClick, $actions: $actionsProp, ...props }: CartRemoveUnavailableProps): import("react/jsx-runtime").JSX.Element | null;
|
|
214
|
+
export declare function ClearCartButton({ className, children, disabled, onClick, $actions: $actionsProp, ...props }: ClearCartButtonProps): import("react/jsx-runtime").JSX.Element | null;
|
|
185
215
|
export declare const CartOpenOnAddDefinition: ComponentDefinition<CartOpenOnAddProps>;
|
|
186
216
|
export declare const CartRedirectOnAddDefinition: ComponentDefinition<CartRedirectOnAddProps>;
|
|
187
217
|
/**
|
package/dist/matter/cart/cart.js
CHANGED
|
@@ -8,17 +8,20 @@ import { graphql } from "../../sdk/generated/gql.js";
|
|
|
8
8
|
import { useActionsOverride } from "../../sdk/actions/actions-override-context.js";
|
|
9
9
|
import { useDataOverride } from "../../sdk/data/data-override-context.js";
|
|
10
10
|
import { NavigationLink } from "../../particles/navigation-link/navigation-link.js";
|
|
11
|
+
import { loggableErrorName } from "../../utils/loggable-error-name.js";
|
|
11
12
|
import { ListItemRefContext } from "../../sdk/data/list-item-ref-context.js";
|
|
12
13
|
import { ReactiveRootContext } from "../../sdk/data/page-reactive-data-root.js";
|
|
14
|
+
import { useOptionalToast } from "../../particles/toast/toast.js";
|
|
13
15
|
import { Icon } from "../../particles/icon/icon.js";
|
|
14
16
|
import { DrawerClose } from "../../particles/drawer/drawer.js";
|
|
15
17
|
import { Image } from "../../particles/image/image.js";
|
|
16
18
|
import { cartCouponErrorsVar, cartLastAddVar, cartUserErrorsVar, miniCartOpenVar, orderFormIdVar } from "../../sdk/state/cart.js";
|
|
17
19
|
import { awaitCartWrites } from "../../sdk/cart/write-gate.js";
|
|
18
20
|
import { readCartFromCache } from "../../sdk/cart/use-cart-actions.js";
|
|
21
|
+
import { useCartSyncSalesChannel } from "../../sdk/cart/use-cart-sync-sales-channel.js";
|
|
19
22
|
import { useCartValidateOnOpen } from "../../sdk/cart/use-cart-validate-on-open.js";
|
|
20
|
-
import { useApolloClient, useReactiveVar } from "@apollo/client/react";
|
|
21
|
-
import { cloneElement, createContext, isValidElement, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
23
|
+
import { getApolloContext, useApolloClient, useReactiveVar } from "@apollo/client/react";
|
|
24
|
+
import { cloneElement, createContext, isValidElement, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
22
25
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
23
26
|
import { useLinkStatus } from "next/link";
|
|
24
27
|
//#region src/matter/cart/cart.tsx
|
|
@@ -88,6 +91,17 @@ const fragment = graphql(`
|
|
|
88
91
|
code
|
|
89
92
|
isUnmatchedCondition
|
|
90
93
|
}
|
|
94
|
+
discounts {
|
|
95
|
+
name
|
|
96
|
+
value {
|
|
97
|
+
...MoneyFragment
|
|
98
|
+
}
|
|
99
|
+
kind
|
|
100
|
+
}
|
|
101
|
+
salesChannelMismatch {
|
|
102
|
+
cartSalesChannel
|
|
103
|
+
activeSalesChannel
|
|
104
|
+
}
|
|
91
105
|
}
|
|
92
106
|
}
|
|
93
107
|
`);
|
|
@@ -97,6 +111,17 @@ function formatPrice(value, locale, currency) {
|
|
|
97
111
|
currency
|
|
98
112
|
}).format(value);
|
|
99
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* True when a money amount can be read as a number: a finite `number` (the optimistic-cache shape) or
|
|
116
|
+
* a non-blank string `Number` parses to a finite value (the wire shape, a decimal string). Blank and
|
|
117
|
+
* nullish amounts are rejected before `Number()` runs, because `Number('')` and `Number(null)` are `0`
|
|
118
|
+
* and would turn a missing amount into a real zero.
|
|
119
|
+
*/
|
|
120
|
+
function isFiniteAmount(value) {
|
|
121
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
122
|
+
if (typeof value === "string") return value.trim() !== "" && Number.isFinite(Number(value));
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
100
125
|
const CartTotalValueContext = createContext(null);
|
|
101
126
|
const CART_DATA_UNSET = Symbol("CartDataContextUnset");
|
|
102
127
|
const CartDataContextInternal = createContext(CART_DATA_UNSET);
|
|
@@ -126,7 +151,8 @@ const CartRootDefinition = defineComponent({
|
|
|
126
151
|
category: "commerce"
|
|
127
152
|
},
|
|
128
153
|
schema: {},
|
|
129
|
-
|
|
154
|
+
actions: { cart: ["syncSalesChannel"] },
|
|
155
|
+
guideline: "Cart data provider hosted by the layout (shared shell), wrapping the slot so every page consumes its context; exactly one per tree — do not place it as a page root. To build a mini-cart, wrap this CartRoot subtree in a modal DrawerRoot: the header carries a DrawerTrigger with a CartCount badge, the DrawerPopup body is a CartList line-item template, and its footer is CartTotal plus CartGoCheckout. The mini-cart is this layout composition, not a dedicated component. See cart.md. On load, a cart whose sales channel differs from the request is moved onto the active channel."
|
|
130
156
|
});
|
|
131
157
|
const CartListDefinition = defineComponent({
|
|
132
158
|
name: "CartList",
|
|
@@ -166,12 +192,18 @@ const CartCountDefinition = defineComponent({
|
|
|
166
192
|
label: "Cart Count",
|
|
167
193
|
category: "commerce"
|
|
168
194
|
},
|
|
169
|
-
schema: {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
195
|
+
schema: {
|
|
196
|
+
template: {
|
|
197
|
+
type: "string",
|
|
198
|
+
default: "{count}",
|
|
199
|
+
label: "Template"
|
|
200
|
+
},
|
|
201
|
+
templateOne: {
|
|
202
|
+
type: "string",
|
|
203
|
+
label: "Template (one)"
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
guideline: "Renders the total item count in the cart; use the template prop to customize the format (e.g. '{count} produtos'). Set templateOne (e.g. '{count} produto') to word the count of exactly 1; template covers every other count, including 0, and is also used when templateOne is unset. A count that is not a finite number renders nothing. Gift lines are excluded from the count — a promotional gift is not something the shopper added — so a cart holding only gifts shows 0. In a mini-cart, place it as the badge on the header DrawerTrigger and again in the DrawerPopup header. Must be inside CartRoot."
|
|
175
207
|
});
|
|
176
208
|
const CartErrorDefinition = defineComponent({
|
|
177
209
|
name: "CartError",
|
|
@@ -224,10 +256,15 @@ const CartCouponFormDefinition = defineComponent({
|
|
|
224
256
|
applyLabel: {
|
|
225
257
|
type: "string",
|
|
226
258
|
label: "Apply Label"
|
|
259
|
+
},
|
|
260
|
+
appliedMessage: {
|
|
261
|
+
type: "string",
|
|
262
|
+
default: "Coupon applied",
|
|
263
|
+
label: "Applied message"
|
|
227
264
|
}
|
|
228
265
|
},
|
|
229
266
|
actions: { cart: ["applyCoupon"] },
|
|
230
|
-
guideline: "Coupon code input plus an apply button; root-agnostic (dispatches $actions.cart.applyCoupon). While an apply is in flight it disables the input and button and exposes data-fs-cart-coupon-pending. In a mini-cart it sits in the DrawerPopup footer above the totals; pair it with CartAppliedCoupons (the applied list) and CartCouponError (the error banner). Must be inside CartRoot."
|
|
267
|
+
guideline: "Coupon code input plus an apply button; root-agnostic (dispatches $actions.cart.applyCoupon). While an apply is in flight it disables the input and button and exposes data-fs-cart-coupon-pending. In a mini-cart it sits in the DrawerPopup footer above the totals; pair it with CartAppliedCoupons (the applied list) and CartCouponError (the error banner). For a single-coupon store, wrap the entry (the accordion holding this form) in CartCouponEmpty so it hides once a code is applied. When an apply returns no errors and the submitted code comes back matched, it raises a toast titled appliedMessage (needs a ToastProvider with a ToastList in the layout; with none, no toast shows and the apply still works). An unmatched code raises no toast; compose CartCouponUnmatched in the chip for that case. The toast still shows when CartCouponEmpty removes the form. Must be inside CartRoot."
|
|
231
268
|
});
|
|
232
269
|
const CartAppliedCouponsDefinition = defineComponent({
|
|
233
270
|
name: "CartAppliedCoupons",
|
|
@@ -239,7 +276,7 @@ const CartAppliedCouponsDefinition = defineComponent({
|
|
|
239
276
|
},
|
|
240
277
|
schema: {},
|
|
241
278
|
actions: { cart: ["removeCoupon"] },
|
|
242
|
-
guideline: "Renders one chip per applied coupon (cart.appliedCoupons), each showing its code and a CartCouponRemove control; renders nothing when no coupons are applied. A coupon whose conditions did not match is marked with data-fs-cart-coupon-unmatched. Place it next to CartCouponForm in the mini-cart footer. Must be inside CartRoot."
|
|
279
|
+
guideline: "Renders one chip per applied coupon (cart.appliedCoupons), each showing its code and a CartCouponRemove control; renders nothing when no coupons are applied. A coupon whose conditions did not match is marked with data-fs-cart-coupon-unmatched. Place it next to CartCouponForm in the mini-cart footer. Composed children replace the built-in remove control, so a chip template that adds CartCouponUnmatched (the unmatched-coupon notice) or CartCouponSavings (the amount the coupon saves) must also compose CartCouponRemove. Must be inside CartRoot."
|
|
243
280
|
});
|
|
244
281
|
const CartCouponRemoveDefinition = defineComponent({
|
|
245
282
|
name: "CartCouponRemove",
|
|
@@ -267,13 +304,62 @@ const CartCouponErrorDefinition = defineComponent({
|
|
|
267
304
|
schema: {},
|
|
268
305
|
guideline: "Inline error banner that surfaces coupon apply/remove errors next to the CartCouponForm; renders nothing when there are none. Reads a dedicated coupon error channel, separate from CartError. Must be inside CartRoot."
|
|
269
306
|
});
|
|
270
|
-
|
|
271
|
-
|
|
307
|
+
const CartCouponEmptyDefinition = defineComponent({
|
|
308
|
+
name: "CartCouponEmpty",
|
|
309
|
+
importPath: "@vtex/faststore/components",
|
|
310
|
+
component: CartCouponEmpty,
|
|
311
|
+
editor: {
|
|
312
|
+
label: "Cart Coupon Empty",
|
|
313
|
+
category: "commerce"
|
|
314
|
+
},
|
|
315
|
+
schema: {},
|
|
316
|
+
guideline: "Coupon entry gate: renders its children only while the resolved cart has no applied coupon (cart.appliedCoupons is empty), and nothing while the cart loads. The merchant coupon policy is composition: for a single-coupon store, wrap the coupon entry (the AccordionRoot holding CartCouponForm) in it so the entry hides once a code is applied and returns when the chip is removed; for a multi-coupon store, omit it so the entry stays open for more codes. Keep CartAppliedCoupons and CartCouponError outside it, so the applied chips and coupon errors stay visible. Must be inside CartRoot. See cart.md."
|
|
317
|
+
});
|
|
318
|
+
const CartCouponUnmatchedDefinition = defineComponent({
|
|
319
|
+
name: "CartCouponUnmatched",
|
|
320
|
+
importPath: "@vtex/faststore/components",
|
|
321
|
+
component: CartCouponUnmatched,
|
|
322
|
+
editor: {
|
|
323
|
+
label: "Cart Coupon Unmatched",
|
|
324
|
+
category: "commerce"
|
|
325
|
+
},
|
|
326
|
+
schema: { message: {
|
|
327
|
+
type: "string",
|
|
328
|
+
default: "This coupon is not being applied to your cart",
|
|
329
|
+
label: "Message"
|
|
330
|
+
} },
|
|
331
|
+
guideline: "Per-chip notice for an applied coupon that grants nothing: renders the message copy in an <output> live region only while the enclosing chip's coupon has isUnmatchedCondition (its conditions stopped matching, were never met, or the code was accepted without validation), and nothing once it matches again, outside a chip, or when the copy is blank. Place it inside CartAppliedCoupons next to CartCouponRemove: composed children replace the built-in remove control, so a chip template without CartCouponRemove loses the X. It does not remove the coupon; the shopper removes it with the X. See cart.md."
|
|
332
|
+
});
|
|
333
|
+
const CartCouponSavingsDefinition = defineComponent({
|
|
334
|
+
name: "CartCouponSavings",
|
|
335
|
+
importPath: "@vtex/faststore/components",
|
|
336
|
+
component: CartCouponSavings,
|
|
337
|
+
editor: {
|
|
338
|
+
label: "Cart Coupon Savings",
|
|
339
|
+
category: "commerce"
|
|
340
|
+
},
|
|
341
|
+
schema: { template: {
|
|
342
|
+
type: "string",
|
|
343
|
+
default: "{amount}",
|
|
344
|
+
label: "Template"
|
|
345
|
+
} },
|
|
346
|
+
guideline: "Per-chip amount a fixed-amount coupon took off, summed from cart.discounts for the enclosing chip's code. Renders nothing for an unmatched, free-shipping or percentage coupon (the API attributes no amount to them), outside a chip, or when the sum is not above zero. Set template to word the chip text, e.g. 'Economia de {amount}' or '{code} — Economia de {amount}': every {amount} becomes the saving and every {code} the chip's code; the default is '{amount}' and a blank template counts as unset. The chip already shows the code before its children, so {code} repeats it. Place it inside a CartAppliedCoupons chip template next to CartCouponRemove: composed children replace the built-in remove control, so a chip template without CartCouponRemove loses the X. Must be inside CartRoot. See cart.md."
|
|
347
|
+
});
|
|
348
|
+
const useIsomorphicLayoutEffect = globalThis.window === void 0 ? useEffect : useLayoutEffect;
|
|
349
|
+
function CartRoot({ $data: $dataProp, $actions: $actionsProp, className, children, ...props }) {
|
|
350
|
+
const $data = useDataOverride($dataProp);
|
|
351
|
+
const $actions = useActionsOverride($actionsProp);
|
|
352
|
+
const cart = $data ?? null;
|
|
353
|
+
useCartSyncSalesChannel($actions?.cart?.syncSalesChannel, cart?.id ?? null, cart?.salesChannelMismatch);
|
|
272
354
|
const { error: rootError } = useContext(ReactiveRootContext);
|
|
273
355
|
const cartEntityId = cart?.id ?? null;
|
|
274
356
|
useEffect(() => {
|
|
275
357
|
if (cartEntityId) orderFormIdVar(cartEntityId);
|
|
276
358
|
}, [cartEntityId]);
|
|
359
|
+
useIsomorphicLayoutEffect(() => {
|
|
360
|
+
cartUserErrorsVar([]);
|
|
361
|
+
cartCouponErrorsVar([]);
|
|
362
|
+
}, []);
|
|
277
363
|
const dataValue = useMemo(() => ({
|
|
278
364
|
cart,
|
|
279
365
|
error: rootError ?? null
|
|
@@ -318,7 +404,7 @@ function CartList({ className, children, skeletonCount = 3, ...props }) {
|
|
|
318
404
|
function CartTotal({ label, className, children, ...props }) {
|
|
319
405
|
const total = useContext(CartTotalValueContext);
|
|
320
406
|
const { locale, currency } = useStorefrontContext();
|
|
321
|
-
const value = children ?? formatPrice(total?.amount ?? 0, locale, currency);
|
|
407
|
+
const value = children ?? formatPrice(Number(total?.amount ?? 0), locale, currency);
|
|
322
408
|
return /* @__PURE__ */ jsx("span", {
|
|
323
409
|
...props,
|
|
324
410
|
className,
|
|
@@ -327,15 +413,28 @@ function CartTotal({ label, className, children, ...props }) {
|
|
|
327
413
|
children: label == null ? value : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", { children: label }), /* @__PURE__ */ jsx("span", { children: value })] })
|
|
328
414
|
});
|
|
329
415
|
}
|
|
330
|
-
|
|
416
|
+
/**
|
|
417
|
+
* Fills `{count}` in the template for the count. `templateOne` is used only at exactly 1 and only when
|
|
418
|
+
* it is not blank. A count that is not a finite number yields `null`.
|
|
419
|
+
*/
|
|
420
|
+
function formatCount(count, template, templateOne) {
|
|
421
|
+
if (!Number.isFinite(count)) return null;
|
|
422
|
+
return (count === 1 && templateOne?.trim() ? templateOne : template).replace("{count}", String(count));
|
|
423
|
+
}
|
|
424
|
+
function addToCount(sum, item) {
|
|
425
|
+
if (item.gift) return sum;
|
|
426
|
+
return Number.isFinite(item.quantity) ? sum + item.quantity : NaN;
|
|
427
|
+
}
|
|
428
|
+
function CartCount({ className, children, template = "{count}", templateOne, ...props }) {
|
|
331
429
|
const { cart } = useCart();
|
|
332
|
-
const count = cart?.items.reduce(
|
|
430
|
+
const count = cart?.items.reduce(addToCount, 0) ?? 0;
|
|
431
|
+
if (!Number.isFinite(count)) return null;
|
|
333
432
|
return /* @__PURE__ */ jsx("span", {
|
|
334
433
|
...props,
|
|
335
434
|
className,
|
|
336
435
|
"data-fs-cart-count": "",
|
|
337
436
|
"data-fs-text": "",
|
|
338
|
-
children: children ??
|
|
437
|
+
children: children ?? formatCount(count, template, templateOne)
|
|
339
438
|
});
|
|
340
439
|
}
|
|
341
440
|
function CartError({ className, children, ...props }) {
|
|
@@ -403,8 +502,10 @@ function CartGoCheckout({ href = CHECKOUT_PAGE, label, className, children, onCl
|
|
|
403
502
|
children: /* @__PURE__ */ jsx(CartGoCheckoutPending, { children: resolvedLabel })
|
|
404
503
|
});
|
|
405
504
|
}
|
|
406
|
-
function CartCouponForm({ placeholder = "Coupon code", applyLabel = "Apply", className, children, onSubmit, $actions: $actionsProp, ...props }) {
|
|
505
|
+
function CartCouponForm({ placeholder = "Coupon code", applyLabel = "Apply", appliedMessage = "Coupon applied", className, children, onSubmit, $actions: $actionsProp, ...props }) {
|
|
407
506
|
const $actions = useActionsOverride($actionsProp);
|
|
507
|
+
const toast = useOptionalToast();
|
|
508
|
+
const { client } = useContext(getApolloContext());
|
|
408
509
|
const [code, setCode] = useState("");
|
|
409
510
|
const [pending, setPending] = useState(false);
|
|
410
511
|
async function handleSubmit(e) {
|
|
@@ -416,6 +517,13 @@ function CartCouponForm({ placeholder = "Coupon code", applyLabel = "Apply", cla
|
|
|
416
517
|
try {
|
|
417
518
|
const errors = await $actions?.cart?.applyCoupon?.({ code: trimmed });
|
|
418
519
|
if (!errors || errors.length === 0) setCode("");
|
|
520
|
+
if (errors?.length === 0 && client && appliedMessage?.trim()) {
|
|
521
|
+
const submitted = trimmed.toLowerCase();
|
|
522
|
+
if ((readCartFromCache(client)?.appliedCoupons ?? []).some((coupon) => coupon.code.trim().toLowerCase() === submitted && coupon.isUnmatchedCondition === false)) toast?.add({
|
|
523
|
+
title: appliedMessage,
|
|
524
|
+
type: "success"
|
|
525
|
+
});
|
|
526
|
+
}
|
|
419
527
|
} finally {
|
|
420
528
|
setPending(false);
|
|
421
529
|
}
|
|
@@ -508,6 +616,52 @@ function CartCouponError({ className, children, ...props }) {
|
|
|
508
616
|
children: children ?? firstError.message
|
|
509
617
|
});
|
|
510
618
|
}
|
|
619
|
+
function CartCouponEmpty({ className, children, ...props }) {
|
|
620
|
+
const { cart } = useCart();
|
|
621
|
+
if (cart == null || (cart.appliedCoupons ?? []).length > 0) return null;
|
|
622
|
+
return /* @__PURE__ */ jsx("div", {
|
|
623
|
+
...props,
|
|
624
|
+
className,
|
|
625
|
+
"data-fs-cart-coupon-empty": "",
|
|
626
|
+
children
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
function CartCouponUnmatched({ message = "This coupon is not being applied to your cart", className, children, ...props }) {
|
|
630
|
+
if (useContext(CartCouponContext)?.isUnmatchedCondition !== true) return null;
|
|
631
|
+
if (children == null && !message?.trim()) return null;
|
|
632
|
+
return /* @__PURE__ */ jsx("output", {
|
|
633
|
+
...props,
|
|
634
|
+
className,
|
|
635
|
+
"data-fs-cart-coupon-unmatched-notice": "",
|
|
636
|
+
"data-fs-text": "",
|
|
637
|
+
children: children ?? message
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Fills every `{code}` and `{amount}` in one pass. A function replacer keeps `$` sequences in the
|
|
642
|
+
* values literal, and a substituted value is never scanned again for placeholders.
|
|
643
|
+
*/
|
|
644
|
+
function fillCouponTemplate(template, { code, amount }) {
|
|
645
|
+
return template.replaceAll(/\{(code|amount)\}/g, (_, key) => key === "code" ? code : amount);
|
|
646
|
+
}
|
|
647
|
+
function CartCouponSavings({ className, template = "{amount}", ...props }) {
|
|
648
|
+
const coupon = useContext(CartCouponContext);
|
|
649
|
+
const { cart } = useCart();
|
|
650
|
+
const { locale, currency } = useStorefrontContext();
|
|
651
|
+
if (!cart || !coupon || coupon.isUnmatchedCondition || coupon.code === "") return null;
|
|
652
|
+
const saved = cart.discounts.reduce((sum, discount) => discount.kind === "COUPON" && discount.name === coupon.code && isFiniteAmount(discount.value.amount) ? sum + Number(discount.value.amount) : sum, 0);
|
|
653
|
+
if (saved <= 0) return null;
|
|
654
|
+
return /* @__PURE__ */ jsx("span", {
|
|
655
|
+
...props,
|
|
656
|
+
className,
|
|
657
|
+
"data-fs-cart-coupon-savings": "",
|
|
658
|
+
"data-fs-text": "",
|
|
659
|
+
children: fillCouponTemplate(template?.trim() ? template : "{amount}", {
|
|
660
|
+
code: coupon.code,
|
|
661
|
+
amount: formatPrice(-saved, locale, currency)
|
|
662
|
+
})
|
|
663
|
+
});
|
|
664
|
+
}
|
|
511
665
|
const CartCheckoutGuardDefinition = defineComponent({
|
|
512
666
|
name: "CartCheckoutGuard",
|
|
513
667
|
importPath: "@vtex/faststore/components",
|
|
@@ -560,12 +714,18 @@ const CartUnavailableCountDefinition = defineComponent({
|
|
|
560
714
|
label: "Cart Unavailable Count",
|
|
561
715
|
category: "commerce"
|
|
562
716
|
},
|
|
563
|
-
schema: {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
717
|
+
schema: {
|
|
718
|
+
template: {
|
|
719
|
+
type: "string",
|
|
720
|
+
default: "{count} items unavailable",
|
|
721
|
+
label: "Template"
|
|
722
|
+
},
|
|
723
|
+
templateOne: {
|
|
724
|
+
type: "string",
|
|
725
|
+
label: "Template (one)"
|
|
726
|
+
}
|
|
727
|
+
},
|
|
728
|
+
guideline: "Cart-level summary of how many lines are unavailable; self-hides when none. Set templateOne to word the count of exactly 1 line; template covers every other count, including 0, and is also used when templateOne is unset. See cart.md."
|
|
569
729
|
});
|
|
570
730
|
const CartRemoveUnavailableDefinition = defineComponent({
|
|
571
731
|
name: "CartRemoveUnavailable",
|
|
@@ -579,6 +739,18 @@ const CartRemoveUnavailableDefinition = defineComponent({
|
|
|
579
739
|
actions: { cart: ["removeItems"] },
|
|
580
740
|
guideline: "Button that removes every unavailable line in one batch call; self-hides when none. See cart.md."
|
|
581
741
|
});
|
|
742
|
+
const ClearCartButtonDefinition = defineComponent({
|
|
743
|
+
name: "ClearCartButton",
|
|
744
|
+
importPath: "@vtex/faststore/components",
|
|
745
|
+
component: ClearCartButton,
|
|
746
|
+
editor: {
|
|
747
|
+
label: "Clear Cart Button",
|
|
748
|
+
category: "commerce"
|
|
749
|
+
},
|
|
750
|
+
schema: {},
|
|
751
|
+
actions: { cart: ["removeItems"] },
|
|
752
|
+
guideline: "Button that removes every line in the cart (gift and unavailable lines included) in one batch call; self-hides when the cart has no lines. Disabled, with data-fs-clear-cart-button-pending, while the call is in flight. No confirmation and no toast. The write is optimistic: CartEmpty replaces CartFilled as soon as it is clicked; on failure the lines come back and the error shows in CartError, so compose a CartError outside the CartFilled/CartEmpty branches. Children are the label (default \"Clear cart\"). Must be inside CartRoot. See cart.md."
|
|
753
|
+
});
|
|
582
754
|
function isUnavailable(item) {
|
|
583
755
|
return item.variant.availability !== "AVAILABLE";
|
|
584
756
|
}
|
|
@@ -595,7 +767,7 @@ function CartCheckoutGuard({ className, children, ...props }) {
|
|
|
595
767
|
children
|
|
596
768
|
});
|
|
597
769
|
}
|
|
598
|
-
function CartUnavailableCount({ className, children, template = "{count} items unavailable", ...props }) {
|
|
770
|
+
function CartUnavailableCount({ className, children, template = "{count} items unavailable", templateOne, ...props }) {
|
|
599
771
|
const { cart } = useCart();
|
|
600
772
|
const count = (cart?.items ?? []).filter(isUnavailable).length;
|
|
601
773
|
if (count === 0) return null;
|
|
@@ -604,7 +776,7 @@ function CartUnavailableCount({ className, children, template = "{count} items u
|
|
|
604
776
|
className,
|
|
605
777
|
"data-fs-cart-unavailable-count": "",
|
|
606
778
|
"data-fs-text": "",
|
|
607
|
-
children: children ??
|
|
779
|
+
children: children ?? formatCount(count, template, templateOne)
|
|
608
780
|
});
|
|
609
781
|
}
|
|
610
782
|
function CartRemoveUnavailable({ className, children, onClick, $actions: $actionsProp, ...props }) {
|
|
@@ -626,6 +798,44 @@ function CartRemoveUnavailable({ className, children, onClick, $actions: $action
|
|
|
626
798
|
children: children ?? "Remove unavailable items"
|
|
627
799
|
});
|
|
628
800
|
}
|
|
801
|
+
function ClearCartButton({ className, children, disabled, onClick, $actions: $actionsProp, ...props }) {
|
|
802
|
+
const $actions = useActionsOverride($actionsProp);
|
|
803
|
+
const { cart } = useCart();
|
|
804
|
+
const [pending, setPending] = useState(false);
|
|
805
|
+
const inFlight = useRef(false);
|
|
806
|
+
const ids = (cart?.items ?? []).map((item) => item.id);
|
|
807
|
+
if (ids.length === 0) return null;
|
|
808
|
+
async function clear(removeItems) {
|
|
809
|
+
try {
|
|
810
|
+
await removeItems({ ids });
|
|
811
|
+
} catch (error) {
|
|
812
|
+
console.error("[ClearCartButton] removeItems failed", loggableErrorName(error));
|
|
813
|
+
} finally {
|
|
814
|
+
inFlight.current = false;
|
|
815
|
+
setPending(false);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
function handleClick(e) {
|
|
819
|
+
if (inFlight.current) return;
|
|
820
|
+
onClick?.(e);
|
|
821
|
+
const removeItems = $actions?.cart?.removeItems;
|
|
822
|
+
if (typeof removeItems !== "function") return;
|
|
823
|
+
inFlight.current = true;
|
|
824
|
+
setPending(true);
|
|
825
|
+
clear(removeItems);
|
|
826
|
+
}
|
|
827
|
+
return /* @__PURE__ */ jsx("button", {
|
|
828
|
+
...props,
|
|
829
|
+
type: "button",
|
|
830
|
+
className,
|
|
831
|
+
onClick: handleClick,
|
|
832
|
+
disabled: pending || disabled,
|
|
833
|
+
"data-fs-clear-cart-button": "",
|
|
834
|
+
"data-fs-button": "",
|
|
835
|
+
...pending ? { "data-fs-clear-cart-button-pending": "" } : {},
|
|
836
|
+
children: children ?? "Clear cart"
|
|
837
|
+
});
|
|
838
|
+
}
|
|
629
839
|
const CartOpenOnAddDefinition = defineComponent({
|
|
630
840
|
name: "CartOpenOnAdd",
|
|
631
841
|
importPath: "@vtex/faststore/components",
|
|
@@ -876,7 +1086,7 @@ const CartAlertRootDefinition = defineComponent({
|
|
|
876
1086
|
}
|
|
877
1087
|
},
|
|
878
1088
|
providesContext: "cart-alert",
|
|
879
|
-
guideline: "Merchant-authored notice near the top of the mini-cart overlay (a minimum order, a running promotion): wraps CartAlertIcon and CartAlertText in any subset, any order — the arrangement is the composition, not a prop — and renders the glyph then the copy when composed with no children. Its copy and glyph are CMS-editable through the cart-alert content model, with the text, icon, iconUrl and iconAlt props as the non-CMS fallback; it renders nothing when no message is configured, so an unconfigured banner leaves no empty box. Reads no cart data, so it needs no CartRoot ancestor and no cart-state gate — place it inside CartFilled to hide it on an empty cart. A store whose merchants choose the icon must list CART_ALERT_ICON_NAMES under icons.include in
|
|
1089
|
+
guideline: "Merchant-authored notice near the top of the mini-cart overlay (a minimum order, a running promotion): wraps CartAlertIcon and CartAlertText in any subset, any order — the arrangement is the composition, not a prop — and renders the glyph then the copy when composed with no children. Its copy and glyph are CMS-editable through the cart-alert content model, with the text, icon, iconUrl and iconAlt props as the non-CMS fallback; it renders nothing when no message is configured, so an unconfigured banner leaves no empty box. Reads no cart data, so it needs no CartRoot ancestor and no cart-state gate — place it inside CartFilled to hide it on an empty cart. A store whose merchants choose the icon must list CART_ALERT_ICON_NAMES under icons.include in its foundation, or a chosen glyph renders empty. Distinct from CartError (cart mutation errors) and CartUnavailableCount (data-driven). See cart.md."
|
|
880
1090
|
});
|
|
881
1091
|
const CartAlertIconDefinition = defineComponent({
|
|
882
1092
|
name: "CartAlertIcon",
|
|
@@ -1039,6 +1249,6 @@ function CartContinueShopping({ label = "Continue shopping", $content, className
|
|
|
1039
1249
|
});
|
|
1040
1250
|
}
|
|
1041
1251
|
//#endregion
|
|
1042
|
-
export { CART_ALERT_ICON_NAMES, CartAlertContent, CartAlertIcon, CartAlertIconDefinition, CartAlertRoot, CartAlertRootDefinition, CartAlertText, CartAlertTextDefinition, CartAppliedCoupons, CartAppliedCouponsDefinition, CartCheckoutGuard, CartCheckoutGuardDefinition, CartCheckoutLabelContent, CartContinueShopping, CartContinueShoppingContent, CartContinueShoppingDefinition, CartCount, CartCountDefinition, CartCouponError, CartCouponErrorDefinition, CartCouponForm, CartCouponFormDefinition, CartCouponRemove, CartCouponRemoveDefinition, CartDataContext, CartDisclaimer, CartDisclaimerContent, CartDisclaimerDefinition, CartEmpty, CartEmptyDefinition, CartEmptyMessage, CartEmptyMessageContent, CartEmptyMessageDefinition, CartError, CartErrorDefinition, CartFilled, CartFilledDefinition, CartGoCheckout, CartGoCheckoutDefinition, CartItemSkeleton, CartList, CartListDefinition, CartLoading, CartLoadingDefinition, CartOpenOnAdd, CartOpenOnAddDefinition, CartRedirectOnAdd, CartRedirectOnAddDefinition, CartRemoveUnavailable, CartRemoveUnavailableDefinition, CartRoot, CartRootDefinition, CartTotal, CartTotalDefinition, CartTotalValueContext, CartUnavailableCount, CartUnavailableCountDefinition, formatPrice, useCart };
|
|
1252
|
+
export { CART_ALERT_ICON_NAMES, CartAlertContent, CartAlertIcon, CartAlertIconDefinition, CartAlertRoot, CartAlertRootDefinition, CartAlertText, CartAlertTextDefinition, CartAppliedCoupons, CartAppliedCouponsDefinition, CartCheckoutGuard, CartCheckoutGuardDefinition, CartCheckoutLabelContent, CartContinueShopping, CartContinueShoppingContent, CartContinueShoppingDefinition, CartCount, CartCountDefinition, CartCouponEmpty, CartCouponEmptyDefinition, CartCouponError, CartCouponErrorDefinition, CartCouponForm, CartCouponFormDefinition, CartCouponRemove, CartCouponRemoveDefinition, CartCouponSavings, CartCouponSavingsDefinition, CartCouponUnmatched, CartCouponUnmatchedDefinition, CartDataContext, CartDisclaimer, CartDisclaimerContent, CartDisclaimerDefinition, CartEmpty, CartEmptyDefinition, CartEmptyMessage, CartEmptyMessageContent, CartEmptyMessageDefinition, CartError, CartErrorDefinition, CartFilled, CartFilledDefinition, CartGoCheckout, CartGoCheckoutDefinition, CartItemSkeleton, CartList, CartListDefinition, CartLoading, CartLoadingDefinition, CartOpenOnAdd, CartOpenOnAddDefinition, CartRedirectOnAdd, CartRedirectOnAddDefinition, CartRemoveUnavailable, CartRemoveUnavailableDefinition, CartRoot, CartRootDefinition, CartTotal, CartTotalDefinition, CartTotalValueContext, CartUnavailableCount, CartUnavailableCountDefinition, ClearCartButton, ClearCartButtonDefinition, fillCouponTemplate, formatPrice, isFiniteAmount, useCart };
|
|
1043
1253
|
|
|
1044
1254
|
//# sourceMappingURL=cart.js.map
|