@snowcone-app/ui 0.8.3 → 0.9.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/dist/index.d.cts CHANGED
@@ -1623,13 +1623,21 @@ interface AddToCartProps {
1623
1623
  text?: string;
1624
1624
  loadingText?: string;
1625
1625
  successText?: string;
1626
+ /** Button text after a failed add; the error's message is announced in a
1627
+ * `role="alert"` below the button and the button stays enabled to retry. */
1628
+ errorText?: string;
1626
1629
  disabled?: boolean;
1627
1630
  className?: string;
1628
1631
  quantity?: number;
1629
- onClick?: (cartDetail: any) => void;
1632
+ /** Performs the add. Return a Promise and the button waits for it: "Added!"
1633
+ * only after it resolves; a rejection shows the error state. */
1634
+ onClick?: (cartDetail: any) => void | Promise<unknown>;
1630
1635
  onError?: (error: Error) => void;
1636
+ /** Fake delay used only when there is no `onClick` (demos). */
1631
1637
  simulateDelay?: number;
1632
1638
  }
1639
+ /** `data-add-to-cart` on the button — assert on this, not the label text. */
1640
+ type AddToCartStatus = "idle" | "adding" | "added" | "error";
1633
1641
  /**
1634
1642
  * AddToCart - Add to cart button with validation and loading states
1635
1643
  *
@@ -1639,8 +1647,11 @@ interface AddToCartProps {
1639
1647
  *
1640
1648
  * Features:
1641
1649
  * - Automatic selection validation before allowing add
1642
- * - Loading state with customizable text
1643
- * - Success state with visual feedback (green background)
1650
+ * - Loading state with customizable text; waits for an async `onClick`
1651
+ * - Success only after `onClick` resolves; a rejection shows `errorText`
1652
+ * plus the error message in a `role="alert"`, and the button stays
1653
+ * enabled to retry (never a silent "Added!")
1654
+ * - `data-add-to-cart="idle|adding|added|error"` for tests and agents
1644
1655
  * - Automatic cart detail generation with variant info
1645
1656
  * - Simulated delay for cart operations
1646
1657
  * - Screen reader announcements for state changes
@@ -1665,9 +1676,10 @@ interface AddToCartProps {
1665
1676
  * <Product productId="shirt-123">
1666
1677
  * <ProductOptions />
1667
1678
  * <AddToCart
1668
- * onClick={(cartDetail) => {
1669
- * console.log('Added to cart:', cartDetail);
1670
- * // Add to your cart state/API
1679
+ * onClick={async (cartDetail) => {
1680
+ * // Throw (or reject) if the add fails — the button shows the error.
1681
+ * const res = await fetch('/api/cart', { method: 'POST', body: JSON.stringify(cartDetail) });
1682
+ * if (!res.ok) throw new Error('Could not add to cart');
1671
1683
  * }}
1672
1684
  * />
1673
1685
  * </Product>
@@ -1697,24 +1709,22 @@ interface AddToCartProps {
1697
1709
  *
1698
1710
  * @example
1699
1711
  * ```tsx
1700
- * // Faster simulation for testing
1701
- * <AddToCart
1702
- * simulateDelay={500}
1703
- * onClick={(detail) => console.log(detail)}
1704
- * />
1712
+ * // Demo without a real cart: a simulated delay, then "Added!"
1713
+ * <AddToCart simulateDelay={500} />
1705
1714
  * ```
1706
1715
  *
1707
1716
  * @param text - Button text in default state (default: "Add to Bag")
1708
1717
  * @param loadingText - Button text while adding (default: "Adding...")
1709
1718
  * @param successText - Button text after successful add (default: "Added!")
1719
+ * @param errorText - Button text after a failed add (default: "Couldn't add — try again")
1710
1720
  * @param disabled - Force button to disabled state
1711
1721
  * @param className - Additional CSS classes for button
1712
1722
  * @param quantity - Number of items to add (default: 1)
1713
- * @param onClick - Callback with cart detail after successful add
1723
+ * @param onClick - Performs the add with the cart detail; may return a Promise, which the button awaits
1714
1724
  * @param onError - Callback when add fails with error
1715
- * @param simulateDelay - Delay in ms to simulate cart operation (default: 1000)
1725
+ * @param simulateDelay - Delay in ms to simulate a cart operation when there is no `onClick` (default: 1000)
1716
1726
  */
1717
- declare function AddToCart({ text, loadingText, successText, disabled, className, quantity, onClick, onError, simulateDelay, }: AddToCartProps): react_jsx_runtime.JSX.Element;
1727
+ declare function AddToCart({ text, loadingText, successText, errorText, disabled, className, quantity, onClick, onError, simulateDelay, }: AddToCartProps): react_jsx_runtime.JSX.Element;
1718
1728
 
1719
1729
  /**
1720
1730
  * Artwork shape types. Kept here for backwards-compatible imports
@@ -5638,4 +5648,4 @@ declare function normalizeHex(color: string): string;
5638
5648
  */
5639
5649
  declare function scrollInputAboveKeyboard(input: HTMLElement): void;
5640
5650
 
5641
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AddToCart, type AddToCartProps, ArtAlignment, type ArtAlignmentProps, ArtSelector, type ArtSelectorProps, type Artwork, ArtworkCustomizer, type ArtworkCustomizerProps, Badge, type BadgeProps, BrandLogo, type BrandLogoProps, BrandName, type BrandNameProps, Button, type ButtonProps, CanvasEditor, type CanvasExportServiceConfig, CanvasIsolationBoundary, CanvasIsolationConfigurator, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CarouselImage, type CarouselRenderProps, Checkbox, Chip, type ClipShape, Collapsible, CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, ColorPalette, ColorPicker, type ColorPickerProps, ColorRow, ColorSwatch, type ColorSwatchChoice, type ColorSwatchProps, ColorTokenSwatch, type ContentRenderProps, CurrentRefinements, CurrentSelectionDisplay, type CurrentSelectionDisplayProps, DEFAULT_HERO_ZOOM_CONFIG, DEFAULT_IMAGE_CONFIG, DEFAULT_VISIBILITY_OPTIONS, DesignSystemPage, type DeviceDetectionResult, Disclosure, DisclosureContent, DisclosureTrigger, DragHintAnimation, type DragHintAnimationProps, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EdgeBlurBox, type EdgeBlurBoxProps, EdgeSwipeGuards, type EdgeSwipeGuardsProps, EnhancedImageViewer, FACET_SECTIONS, type FacetSection, type FacetType, Fieldset, type FieldsetProps, Filters, FiltersButton, type FiltersButtonProps, FiltersDrawer, type FiltersProps, FloatingActionGroup, type FloatingActionGroupProps, type FloatingActionItem, type FormatCurrencyOptions, HeroCarousel, type HeroCarouselProps, type HeroImage, type HeroImageRenderProps, HeroProductImage, type HeroProductImageProps, type HeroShrinkConfig, HeroShrinkLayout, type HeroShrinkLayoutProps, type HeroZoomConfig, HeroZoomLayout, type HeroZoomLayoutProps, type HeroZoomScales, HorizontalProgressiveBlur, type HorizontalProgressiveBlurProps, Drawer as IOSDrawer, DrawerClose as IOSDrawerClose, DrawerContent as IOSDrawerContent, DrawerDescription as IOSDrawerDescription, DrawerFooter as IOSDrawerFooter, DrawerHeader as IOSDrawerHeader, DrawerTitle as IOSDrawerTitle, DrawerTrigger as IOSDrawerTrigger, ImageBlurExtension, type ImageBlurExtensionProps, ImageEdgeBlur, type ImageEdgeBlurProps, type ImageLayer, type ImageUpdateRequest, Input, type InputProps, Kbd, type KbdProps, Label, Legend, type LegendProps, Lightbox, type LightboxProps, Link, LinkIcon, type LinkProps, LoadingOverlayPrism, LoadingOverlayPrismCandy, LoadingOverlayPrismCandyInline, type LoadingOverlayPrismCandyProps, type LoadingOverlayPrismProps, MasonryGrid, type MasonryGridProps, MobileProductCarousel, type MobileProductCarouselProps, MockupBackground, type MockupBackgroundProps, type MockupPriorityContextValue, MockupPriorityProvider, type MockupPriorityProviderProps, type MockupResult, PDPLayout, type PDPLayoutProps, PersonalizationField, PersonalizationInputs, PersonalizationProvider, PersonalizationValues, PlacementClipShapeSelector, type PlacementConfig, type PlacementDesign, PlacementTabs, type PlacementTabsProps, Popover, PopoverAnchor, PopoverContent, PopoverRoot, PopoverTrigger, type PriorityLevel, Product, ProductCard, type ProductCardProps, ProductContext, type ProductDataMode, ProductGallery, type ProductGalleryProps, ProductGrid, type ProductGridProps, type ProductHit, ProductHitComponent, ProductImage, type Artwork$1 as ProductImageArtwork, type ProductImageProps, ProductList, type ProductListProps, ProductOptions, type ProductPageContext, ProductPageProvider, ProductPageProviderMinimal, type ProductPageProviderMinimalProps, type ProductPageProviderProps, ProductPrice, type ProductPriceProps, type ProductProviderProps, ProgressiveBlur, type ProgressiveBlurProps, type ProviderStatus, Radio, RadioGroup, RadioGroupItem, RadiusScale, type ReactProductContext, type RealtimeContextValue, RealtimeMockup, type RealtimeMockupProps, RealtimeProvider, type RealtimeProviderProps, type RealtimeState, type RegularArtwork$1 as RegularArtwork, type ResponsiveColumns, type ResponsiveImageCapInfo, type ResponsiveImageCapOptions, ResponsiveZoom, RightToLeftProgressiveBlur, type RightToLeftProgressiveBlurProps, SafeImg, type SafeImgProps, type ScrollDirection, ScrollFade, type ScrollFadeProps, type ScrollState, type SeamlessPattern$1 as SeamlessPattern, SearchBox, SearchProvider, type SearchProviderProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Shop, ShopContext, type ShopContextValue, type ShopProps, SimpleImageBlur, type SimpleImageBlurProps, Slider, SliderFill, SliderOutput, SliderThumb, SliderTrack, Spinner, type SpinnerProps, Surface, SurfaceContext, type SurfaceProps, Switch, Tabs, TabsContent, TabsList, TabsRoot, TabsTrigger, TextArea, TextField, type TextFieldProps, Textarea, type TextareaProps, ThemeSwitcher, ThemeToggle, type ThemeToggleProps, TileCount, Tooltip, TooltipContent, TooltipProvider, TooltipRoot, TooltipTrigger, TypographyScale, type UiRouter, UiRouterProvider, type UseBrandResult, type UseImagePreloaderOptions, type UseImagePreloaderReturn, type UseImageTransitionOptions, type UseImageTransitionReturn, type UsePersonalizationShimmerReturn, type UseProductGalleryOptions, type UseProductGalleryReturn, VISIBILITY_THRESHOLDS, type ViewportDimensions, type ZoomImage, ZoomOverlay, badgeVariants, brandAssets, buttonVariants, canvasExportService, checkComponentStyles, checkTailwindConfig, checkThemeTokens, createScrollDirectionTracker, formatCurrency, formatDate, formatDateTime, getBrand, getObservedElementCount, getObserverCount, hasEdgeBlur, isObserved, isWideMonitor, kbdVariants, linkVariants, linkedPlacementsLabel, normalizeHex, observe, runConfigChecks, scrollInputAboveKeyboard, searchClient, spinnerVariants, surfaceVariants, useArtworkAlignment, useBrand, useCanvasContext, useCanvasContextStatic, useCurrentPlacements, useDesign, useDesignOptional, useDeviceDetection, useFocusTrap, useHeroZoomScales, useImagePreloader, useImageTransition, useIsolatedCanvas, useLoadingOverlay, useMediaQuery, useMockupBackgroundOptional, useMockupPriority, useMockupPriorityOptional, usePersonalization, usePersonalizationOptional, usePersonalizationShimmer, usePlacementClipShape, usePlacementsProcessor, useProduct, useProductGallery, useProductOptional, useProductPage, useProductPageOptional, useProductSelection, useProviderStatus, useRealtime, useRealtimeOptional, useRenderCount, useRenderGuard, useResponsiveImageCap, useScrollDirection, useSelectedArtwork, useSetArtworkAlignment, useShop, useShopOptional, useSurface, useViewportDimensions, useWideMonitorMode };
5651
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AddToCart, type AddToCartProps, type AddToCartStatus, ArtAlignment, type ArtAlignmentProps, ArtSelector, type ArtSelectorProps, type Artwork, ArtworkCustomizer, type ArtworkCustomizerProps, Badge, type BadgeProps, BrandLogo, type BrandLogoProps, BrandName, type BrandNameProps, Button, type ButtonProps, CanvasEditor, type CanvasExportServiceConfig, CanvasIsolationBoundary, CanvasIsolationConfigurator, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CarouselImage, type CarouselRenderProps, Checkbox, Chip, type ClipShape, Collapsible, CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, ColorPalette, ColorPicker, type ColorPickerProps, ColorRow, ColorSwatch, type ColorSwatchChoice, type ColorSwatchProps, ColorTokenSwatch, type ContentRenderProps, CurrentRefinements, CurrentSelectionDisplay, type CurrentSelectionDisplayProps, DEFAULT_HERO_ZOOM_CONFIG, DEFAULT_IMAGE_CONFIG, DEFAULT_VISIBILITY_OPTIONS, DesignSystemPage, type DeviceDetectionResult, Disclosure, DisclosureContent, DisclosureTrigger, DragHintAnimation, type DragHintAnimationProps, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EdgeBlurBox, type EdgeBlurBoxProps, EdgeSwipeGuards, type EdgeSwipeGuardsProps, EnhancedImageViewer, FACET_SECTIONS, type FacetSection, type FacetType, Fieldset, type FieldsetProps, Filters, FiltersButton, type FiltersButtonProps, FiltersDrawer, type FiltersProps, FloatingActionGroup, type FloatingActionGroupProps, type FloatingActionItem, type FormatCurrencyOptions, HeroCarousel, type HeroCarouselProps, type HeroImage, type HeroImageRenderProps, HeroProductImage, type HeroProductImageProps, type HeroShrinkConfig, HeroShrinkLayout, type HeroShrinkLayoutProps, type HeroZoomConfig, HeroZoomLayout, type HeroZoomLayoutProps, type HeroZoomScales, HorizontalProgressiveBlur, type HorizontalProgressiveBlurProps, Drawer as IOSDrawer, DrawerClose as IOSDrawerClose, DrawerContent as IOSDrawerContent, DrawerDescription as IOSDrawerDescription, DrawerFooter as IOSDrawerFooter, DrawerHeader as IOSDrawerHeader, DrawerTitle as IOSDrawerTitle, DrawerTrigger as IOSDrawerTrigger, ImageBlurExtension, type ImageBlurExtensionProps, ImageEdgeBlur, type ImageEdgeBlurProps, type ImageLayer, type ImageUpdateRequest, Input, type InputProps, Kbd, type KbdProps, Label, Legend, type LegendProps, Lightbox, type LightboxProps, Link, LinkIcon, type LinkProps, LoadingOverlayPrism, LoadingOverlayPrismCandy, LoadingOverlayPrismCandyInline, type LoadingOverlayPrismCandyProps, type LoadingOverlayPrismProps, MasonryGrid, type MasonryGridProps, MobileProductCarousel, type MobileProductCarouselProps, MockupBackground, type MockupBackgroundProps, type MockupPriorityContextValue, MockupPriorityProvider, type MockupPriorityProviderProps, type MockupResult, PDPLayout, type PDPLayoutProps, PersonalizationField, PersonalizationInputs, PersonalizationProvider, PersonalizationValues, PlacementClipShapeSelector, type PlacementConfig, type PlacementDesign, PlacementTabs, type PlacementTabsProps, Popover, PopoverAnchor, PopoverContent, PopoverRoot, PopoverTrigger, type PriorityLevel, Product, ProductCard, type ProductCardProps, ProductContext, type ProductDataMode, ProductGallery, type ProductGalleryProps, ProductGrid, type ProductGridProps, type ProductHit, ProductHitComponent, ProductImage, type Artwork$1 as ProductImageArtwork, type ProductImageProps, ProductList, type ProductListProps, ProductOptions, type ProductPageContext, ProductPageProvider, ProductPageProviderMinimal, type ProductPageProviderMinimalProps, type ProductPageProviderProps, ProductPrice, type ProductPriceProps, type ProductProviderProps, ProgressiveBlur, type ProgressiveBlurProps, type ProviderStatus, Radio, RadioGroup, RadioGroupItem, RadiusScale, type ReactProductContext, type RealtimeContextValue, RealtimeMockup, type RealtimeMockupProps, RealtimeProvider, type RealtimeProviderProps, type RealtimeState, type RegularArtwork$1 as RegularArtwork, type ResponsiveColumns, type ResponsiveImageCapInfo, type ResponsiveImageCapOptions, ResponsiveZoom, RightToLeftProgressiveBlur, type RightToLeftProgressiveBlurProps, SafeImg, type SafeImgProps, type ScrollDirection, ScrollFade, type ScrollFadeProps, type ScrollState, type SeamlessPattern$1 as SeamlessPattern, SearchBox, SearchProvider, type SearchProviderProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Shop, ShopContext, type ShopContextValue, type ShopProps, SimpleImageBlur, type SimpleImageBlurProps, Slider, SliderFill, SliderOutput, SliderThumb, SliderTrack, Spinner, type SpinnerProps, Surface, SurfaceContext, type SurfaceProps, Switch, Tabs, TabsContent, TabsList, TabsRoot, TabsTrigger, TextArea, TextField, type TextFieldProps, Textarea, type TextareaProps, ThemeSwitcher, ThemeToggle, type ThemeToggleProps, TileCount, Tooltip, TooltipContent, TooltipProvider, TooltipRoot, TooltipTrigger, TypographyScale, type UiRouter, UiRouterProvider, type UseBrandResult, type UseImagePreloaderOptions, type UseImagePreloaderReturn, type UseImageTransitionOptions, type UseImageTransitionReturn, type UsePersonalizationShimmerReturn, type UseProductGalleryOptions, type UseProductGalleryReturn, VISIBILITY_THRESHOLDS, type ViewportDimensions, type ZoomImage, ZoomOverlay, badgeVariants, brandAssets, buttonVariants, canvasExportService, checkComponentStyles, checkTailwindConfig, checkThemeTokens, createScrollDirectionTracker, formatCurrency, formatDate, formatDateTime, getBrand, getObservedElementCount, getObserverCount, hasEdgeBlur, isObserved, isWideMonitor, kbdVariants, linkVariants, linkedPlacementsLabel, normalizeHex, observe, runConfigChecks, scrollInputAboveKeyboard, searchClient, spinnerVariants, surfaceVariants, useArtworkAlignment, useBrand, useCanvasContext, useCanvasContextStatic, useCurrentPlacements, useDesign, useDesignOptional, useDeviceDetection, useFocusTrap, useHeroZoomScales, useImagePreloader, useImageTransition, useIsolatedCanvas, useLoadingOverlay, useMediaQuery, useMockupBackgroundOptional, useMockupPriority, useMockupPriorityOptional, usePersonalization, usePersonalizationOptional, usePersonalizationShimmer, usePlacementClipShape, usePlacementsProcessor, useProduct, useProductGallery, useProductOptional, useProductPage, useProductPageOptional, useProductSelection, useProviderStatus, useRealtime, useRealtimeOptional, useRenderCount, useRenderGuard, useResponsiveImageCap, useScrollDirection, useSelectedArtwork, useSetArtworkAlignment, useShop, useShopOptional, useSurface, useViewportDimensions, useWideMonitorMode };
package/dist/index.d.ts CHANGED
@@ -1623,13 +1623,21 @@ interface AddToCartProps {
1623
1623
  text?: string;
1624
1624
  loadingText?: string;
1625
1625
  successText?: string;
1626
+ /** Button text after a failed add; the error's message is announced in a
1627
+ * `role="alert"` below the button and the button stays enabled to retry. */
1628
+ errorText?: string;
1626
1629
  disabled?: boolean;
1627
1630
  className?: string;
1628
1631
  quantity?: number;
1629
- onClick?: (cartDetail: any) => void;
1632
+ /** Performs the add. Return a Promise and the button waits for it: "Added!"
1633
+ * only after it resolves; a rejection shows the error state. */
1634
+ onClick?: (cartDetail: any) => void | Promise<unknown>;
1630
1635
  onError?: (error: Error) => void;
1636
+ /** Fake delay used only when there is no `onClick` (demos). */
1631
1637
  simulateDelay?: number;
1632
1638
  }
1639
+ /** `data-add-to-cart` on the button — assert on this, not the label text. */
1640
+ type AddToCartStatus = "idle" | "adding" | "added" | "error";
1633
1641
  /**
1634
1642
  * AddToCart - Add to cart button with validation and loading states
1635
1643
  *
@@ -1639,8 +1647,11 @@ interface AddToCartProps {
1639
1647
  *
1640
1648
  * Features:
1641
1649
  * - Automatic selection validation before allowing add
1642
- * - Loading state with customizable text
1643
- * - Success state with visual feedback (green background)
1650
+ * - Loading state with customizable text; waits for an async `onClick`
1651
+ * - Success only after `onClick` resolves; a rejection shows `errorText`
1652
+ * plus the error message in a `role="alert"`, and the button stays
1653
+ * enabled to retry (never a silent "Added!")
1654
+ * - `data-add-to-cart="idle|adding|added|error"` for tests and agents
1644
1655
  * - Automatic cart detail generation with variant info
1645
1656
  * - Simulated delay for cart operations
1646
1657
  * - Screen reader announcements for state changes
@@ -1665,9 +1676,10 @@ interface AddToCartProps {
1665
1676
  * <Product productId="shirt-123">
1666
1677
  * <ProductOptions />
1667
1678
  * <AddToCart
1668
- * onClick={(cartDetail) => {
1669
- * console.log('Added to cart:', cartDetail);
1670
- * // Add to your cart state/API
1679
+ * onClick={async (cartDetail) => {
1680
+ * // Throw (or reject) if the add fails — the button shows the error.
1681
+ * const res = await fetch('/api/cart', { method: 'POST', body: JSON.stringify(cartDetail) });
1682
+ * if (!res.ok) throw new Error('Could not add to cart');
1671
1683
  * }}
1672
1684
  * />
1673
1685
  * </Product>
@@ -1697,24 +1709,22 @@ interface AddToCartProps {
1697
1709
  *
1698
1710
  * @example
1699
1711
  * ```tsx
1700
- * // Faster simulation for testing
1701
- * <AddToCart
1702
- * simulateDelay={500}
1703
- * onClick={(detail) => console.log(detail)}
1704
- * />
1712
+ * // Demo without a real cart: a simulated delay, then "Added!"
1713
+ * <AddToCart simulateDelay={500} />
1705
1714
  * ```
1706
1715
  *
1707
1716
  * @param text - Button text in default state (default: "Add to Bag")
1708
1717
  * @param loadingText - Button text while adding (default: "Adding...")
1709
1718
  * @param successText - Button text after successful add (default: "Added!")
1719
+ * @param errorText - Button text after a failed add (default: "Couldn't add — try again")
1710
1720
  * @param disabled - Force button to disabled state
1711
1721
  * @param className - Additional CSS classes for button
1712
1722
  * @param quantity - Number of items to add (default: 1)
1713
- * @param onClick - Callback with cart detail after successful add
1723
+ * @param onClick - Performs the add with the cart detail; may return a Promise, which the button awaits
1714
1724
  * @param onError - Callback when add fails with error
1715
- * @param simulateDelay - Delay in ms to simulate cart operation (default: 1000)
1725
+ * @param simulateDelay - Delay in ms to simulate a cart operation when there is no `onClick` (default: 1000)
1716
1726
  */
1717
- declare function AddToCart({ text, loadingText, successText, disabled, className, quantity, onClick, onError, simulateDelay, }: AddToCartProps): react_jsx_runtime.JSX.Element;
1727
+ declare function AddToCart({ text, loadingText, successText, errorText, disabled, className, quantity, onClick, onError, simulateDelay, }: AddToCartProps): react_jsx_runtime.JSX.Element;
1718
1728
 
1719
1729
  /**
1720
1730
  * Artwork shape types. Kept here for backwards-compatible imports
@@ -5638,4 +5648,4 @@ declare function normalizeHex(color: string): string;
5638
5648
  */
5639
5649
  declare function scrollInputAboveKeyboard(input: HTMLElement): void;
5640
5650
 
5641
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AddToCart, type AddToCartProps, ArtAlignment, type ArtAlignmentProps, ArtSelector, type ArtSelectorProps, type Artwork, ArtworkCustomizer, type ArtworkCustomizerProps, Badge, type BadgeProps, BrandLogo, type BrandLogoProps, BrandName, type BrandNameProps, Button, type ButtonProps, CanvasEditor, type CanvasExportServiceConfig, CanvasIsolationBoundary, CanvasIsolationConfigurator, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CarouselImage, type CarouselRenderProps, Checkbox, Chip, type ClipShape, Collapsible, CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, ColorPalette, ColorPicker, type ColorPickerProps, ColorRow, ColorSwatch, type ColorSwatchChoice, type ColorSwatchProps, ColorTokenSwatch, type ContentRenderProps, CurrentRefinements, CurrentSelectionDisplay, type CurrentSelectionDisplayProps, DEFAULT_HERO_ZOOM_CONFIG, DEFAULT_IMAGE_CONFIG, DEFAULT_VISIBILITY_OPTIONS, DesignSystemPage, type DeviceDetectionResult, Disclosure, DisclosureContent, DisclosureTrigger, DragHintAnimation, type DragHintAnimationProps, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EdgeBlurBox, type EdgeBlurBoxProps, EdgeSwipeGuards, type EdgeSwipeGuardsProps, EnhancedImageViewer, FACET_SECTIONS, type FacetSection, type FacetType, Fieldset, type FieldsetProps, Filters, FiltersButton, type FiltersButtonProps, FiltersDrawer, type FiltersProps, FloatingActionGroup, type FloatingActionGroupProps, type FloatingActionItem, type FormatCurrencyOptions, HeroCarousel, type HeroCarouselProps, type HeroImage, type HeroImageRenderProps, HeroProductImage, type HeroProductImageProps, type HeroShrinkConfig, HeroShrinkLayout, type HeroShrinkLayoutProps, type HeroZoomConfig, HeroZoomLayout, type HeroZoomLayoutProps, type HeroZoomScales, HorizontalProgressiveBlur, type HorizontalProgressiveBlurProps, Drawer as IOSDrawer, DrawerClose as IOSDrawerClose, DrawerContent as IOSDrawerContent, DrawerDescription as IOSDrawerDescription, DrawerFooter as IOSDrawerFooter, DrawerHeader as IOSDrawerHeader, DrawerTitle as IOSDrawerTitle, DrawerTrigger as IOSDrawerTrigger, ImageBlurExtension, type ImageBlurExtensionProps, ImageEdgeBlur, type ImageEdgeBlurProps, type ImageLayer, type ImageUpdateRequest, Input, type InputProps, Kbd, type KbdProps, Label, Legend, type LegendProps, Lightbox, type LightboxProps, Link, LinkIcon, type LinkProps, LoadingOverlayPrism, LoadingOverlayPrismCandy, LoadingOverlayPrismCandyInline, type LoadingOverlayPrismCandyProps, type LoadingOverlayPrismProps, MasonryGrid, type MasonryGridProps, MobileProductCarousel, type MobileProductCarouselProps, MockupBackground, type MockupBackgroundProps, type MockupPriorityContextValue, MockupPriorityProvider, type MockupPriorityProviderProps, type MockupResult, PDPLayout, type PDPLayoutProps, PersonalizationField, PersonalizationInputs, PersonalizationProvider, PersonalizationValues, PlacementClipShapeSelector, type PlacementConfig, type PlacementDesign, PlacementTabs, type PlacementTabsProps, Popover, PopoverAnchor, PopoverContent, PopoverRoot, PopoverTrigger, type PriorityLevel, Product, ProductCard, type ProductCardProps, ProductContext, type ProductDataMode, ProductGallery, type ProductGalleryProps, ProductGrid, type ProductGridProps, type ProductHit, ProductHitComponent, ProductImage, type Artwork$1 as ProductImageArtwork, type ProductImageProps, ProductList, type ProductListProps, ProductOptions, type ProductPageContext, ProductPageProvider, ProductPageProviderMinimal, type ProductPageProviderMinimalProps, type ProductPageProviderProps, ProductPrice, type ProductPriceProps, type ProductProviderProps, ProgressiveBlur, type ProgressiveBlurProps, type ProviderStatus, Radio, RadioGroup, RadioGroupItem, RadiusScale, type ReactProductContext, type RealtimeContextValue, RealtimeMockup, type RealtimeMockupProps, RealtimeProvider, type RealtimeProviderProps, type RealtimeState, type RegularArtwork$1 as RegularArtwork, type ResponsiveColumns, type ResponsiveImageCapInfo, type ResponsiveImageCapOptions, ResponsiveZoom, RightToLeftProgressiveBlur, type RightToLeftProgressiveBlurProps, SafeImg, type SafeImgProps, type ScrollDirection, ScrollFade, type ScrollFadeProps, type ScrollState, type SeamlessPattern$1 as SeamlessPattern, SearchBox, SearchProvider, type SearchProviderProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Shop, ShopContext, type ShopContextValue, type ShopProps, SimpleImageBlur, type SimpleImageBlurProps, Slider, SliderFill, SliderOutput, SliderThumb, SliderTrack, Spinner, type SpinnerProps, Surface, SurfaceContext, type SurfaceProps, Switch, Tabs, TabsContent, TabsList, TabsRoot, TabsTrigger, TextArea, TextField, type TextFieldProps, Textarea, type TextareaProps, ThemeSwitcher, ThemeToggle, type ThemeToggleProps, TileCount, Tooltip, TooltipContent, TooltipProvider, TooltipRoot, TooltipTrigger, TypographyScale, type UiRouter, UiRouterProvider, type UseBrandResult, type UseImagePreloaderOptions, type UseImagePreloaderReturn, type UseImageTransitionOptions, type UseImageTransitionReturn, type UsePersonalizationShimmerReturn, type UseProductGalleryOptions, type UseProductGalleryReturn, VISIBILITY_THRESHOLDS, type ViewportDimensions, type ZoomImage, ZoomOverlay, badgeVariants, brandAssets, buttonVariants, canvasExportService, checkComponentStyles, checkTailwindConfig, checkThemeTokens, createScrollDirectionTracker, formatCurrency, formatDate, formatDateTime, getBrand, getObservedElementCount, getObserverCount, hasEdgeBlur, isObserved, isWideMonitor, kbdVariants, linkVariants, linkedPlacementsLabel, normalizeHex, observe, runConfigChecks, scrollInputAboveKeyboard, searchClient, spinnerVariants, surfaceVariants, useArtworkAlignment, useBrand, useCanvasContext, useCanvasContextStatic, useCurrentPlacements, useDesign, useDesignOptional, useDeviceDetection, useFocusTrap, useHeroZoomScales, useImagePreloader, useImageTransition, useIsolatedCanvas, useLoadingOverlay, useMediaQuery, useMockupBackgroundOptional, useMockupPriority, useMockupPriorityOptional, usePersonalization, usePersonalizationOptional, usePersonalizationShimmer, usePlacementClipShape, usePlacementsProcessor, useProduct, useProductGallery, useProductOptional, useProductPage, useProductPageOptional, useProductSelection, useProviderStatus, useRealtime, useRealtimeOptional, useRenderCount, useRenderGuard, useResponsiveImageCap, useScrollDirection, useSelectedArtwork, useSetArtworkAlignment, useShop, useShopOptional, useSurface, useViewportDimensions, useWideMonitorMode };
5651
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AddToCart, type AddToCartProps, type AddToCartStatus, ArtAlignment, type ArtAlignmentProps, ArtSelector, type ArtSelectorProps, type Artwork, ArtworkCustomizer, type ArtworkCustomizerProps, Badge, type BadgeProps, BrandLogo, type BrandLogoProps, BrandName, type BrandNameProps, Button, type ButtonProps, CanvasEditor, type CanvasExportServiceConfig, CanvasIsolationBoundary, CanvasIsolationConfigurator, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CarouselImage, type CarouselRenderProps, Checkbox, Chip, type ClipShape, Collapsible, CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, ColorPalette, ColorPicker, type ColorPickerProps, ColorRow, ColorSwatch, type ColorSwatchChoice, type ColorSwatchProps, ColorTokenSwatch, type ContentRenderProps, CurrentRefinements, CurrentSelectionDisplay, type CurrentSelectionDisplayProps, DEFAULT_HERO_ZOOM_CONFIG, DEFAULT_IMAGE_CONFIG, DEFAULT_VISIBILITY_OPTIONS, DesignSystemPage, type DeviceDetectionResult, Disclosure, DisclosureContent, DisclosureTrigger, DragHintAnimation, type DragHintAnimationProps, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EdgeBlurBox, type EdgeBlurBoxProps, EdgeSwipeGuards, type EdgeSwipeGuardsProps, EnhancedImageViewer, FACET_SECTIONS, type FacetSection, type FacetType, Fieldset, type FieldsetProps, Filters, FiltersButton, type FiltersButtonProps, FiltersDrawer, type FiltersProps, FloatingActionGroup, type FloatingActionGroupProps, type FloatingActionItem, type FormatCurrencyOptions, HeroCarousel, type HeroCarouselProps, type HeroImage, type HeroImageRenderProps, HeroProductImage, type HeroProductImageProps, type HeroShrinkConfig, HeroShrinkLayout, type HeroShrinkLayoutProps, type HeroZoomConfig, HeroZoomLayout, type HeroZoomLayoutProps, type HeroZoomScales, HorizontalProgressiveBlur, type HorizontalProgressiveBlurProps, Drawer as IOSDrawer, DrawerClose as IOSDrawerClose, DrawerContent as IOSDrawerContent, DrawerDescription as IOSDrawerDescription, DrawerFooter as IOSDrawerFooter, DrawerHeader as IOSDrawerHeader, DrawerTitle as IOSDrawerTitle, DrawerTrigger as IOSDrawerTrigger, ImageBlurExtension, type ImageBlurExtensionProps, ImageEdgeBlur, type ImageEdgeBlurProps, type ImageLayer, type ImageUpdateRequest, Input, type InputProps, Kbd, type KbdProps, Label, Legend, type LegendProps, Lightbox, type LightboxProps, Link, LinkIcon, type LinkProps, LoadingOverlayPrism, LoadingOverlayPrismCandy, LoadingOverlayPrismCandyInline, type LoadingOverlayPrismCandyProps, type LoadingOverlayPrismProps, MasonryGrid, type MasonryGridProps, MobileProductCarousel, type MobileProductCarouselProps, MockupBackground, type MockupBackgroundProps, type MockupPriorityContextValue, MockupPriorityProvider, type MockupPriorityProviderProps, type MockupResult, PDPLayout, type PDPLayoutProps, PersonalizationField, PersonalizationInputs, PersonalizationProvider, PersonalizationValues, PlacementClipShapeSelector, type PlacementConfig, type PlacementDesign, PlacementTabs, type PlacementTabsProps, Popover, PopoverAnchor, PopoverContent, PopoverRoot, PopoverTrigger, type PriorityLevel, Product, ProductCard, type ProductCardProps, ProductContext, type ProductDataMode, ProductGallery, type ProductGalleryProps, ProductGrid, type ProductGridProps, type ProductHit, ProductHitComponent, ProductImage, type Artwork$1 as ProductImageArtwork, type ProductImageProps, ProductList, type ProductListProps, ProductOptions, type ProductPageContext, ProductPageProvider, ProductPageProviderMinimal, type ProductPageProviderMinimalProps, type ProductPageProviderProps, ProductPrice, type ProductPriceProps, type ProductProviderProps, ProgressiveBlur, type ProgressiveBlurProps, type ProviderStatus, Radio, RadioGroup, RadioGroupItem, RadiusScale, type ReactProductContext, type RealtimeContextValue, RealtimeMockup, type RealtimeMockupProps, RealtimeProvider, type RealtimeProviderProps, type RealtimeState, type RegularArtwork$1 as RegularArtwork, type ResponsiveColumns, type ResponsiveImageCapInfo, type ResponsiveImageCapOptions, ResponsiveZoom, RightToLeftProgressiveBlur, type RightToLeftProgressiveBlurProps, SafeImg, type SafeImgProps, type ScrollDirection, ScrollFade, type ScrollFadeProps, type ScrollState, type SeamlessPattern$1 as SeamlessPattern, SearchBox, SearchProvider, type SearchProviderProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Shop, ShopContext, type ShopContextValue, type ShopProps, SimpleImageBlur, type SimpleImageBlurProps, Slider, SliderFill, SliderOutput, SliderThumb, SliderTrack, Spinner, type SpinnerProps, Surface, SurfaceContext, type SurfaceProps, Switch, Tabs, TabsContent, TabsList, TabsRoot, TabsTrigger, TextArea, TextField, type TextFieldProps, Textarea, type TextareaProps, ThemeSwitcher, ThemeToggle, type ThemeToggleProps, TileCount, Tooltip, TooltipContent, TooltipProvider, TooltipRoot, TooltipTrigger, TypographyScale, type UiRouter, UiRouterProvider, type UseBrandResult, type UseImagePreloaderOptions, type UseImagePreloaderReturn, type UseImageTransitionOptions, type UseImageTransitionReturn, type UsePersonalizationShimmerReturn, type UseProductGalleryOptions, type UseProductGalleryReturn, VISIBILITY_THRESHOLDS, type ViewportDimensions, type ZoomImage, ZoomOverlay, badgeVariants, brandAssets, buttonVariants, canvasExportService, checkComponentStyles, checkTailwindConfig, checkThemeTokens, createScrollDirectionTracker, formatCurrency, formatDate, formatDateTime, getBrand, getObservedElementCount, getObserverCount, hasEdgeBlur, isObserved, isWideMonitor, kbdVariants, linkVariants, linkedPlacementsLabel, normalizeHex, observe, runConfigChecks, scrollInputAboveKeyboard, searchClient, spinnerVariants, surfaceVariants, useArtworkAlignment, useBrand, useCanvasContext, useCanvasContextStatic, useCurrentPlacements, useDesign, useDesignOptional, useDeviceDetection, useFocusTrap, useHeroZoomScales, useImagePreloader, useImageTransition, useIsolatedCanvas, useLoadingOverlay, useMediaQuery, useMockupBackgroundOptional, useMockupPriority, useMockupPriorityOptional, usePersonalization, usePersonalizationOptional, usePersonalizationShimmer, usePlacementClipShape, usePlacementsProcessor, useProduct, useProductGallery, useProductOptional, useProductPage, useProductPageOptional, useProductSelection, useProviderStatus, useRealtime, useRealtimeOptional, useRenderCount, useRenderGuard, useResponsiveImageCap, useScrollDirection, useSelectedArtwork, useSetArtworkAlignment, useShop, useShopOptional, useSurface, useViewportDimensions, useWideMonitorMode };
package/dist/index.js CHANGED
@@ -4554,6 +4554,7 @@ function AddToCart({
4554
4554
  text = "Add to Bag",
4555
4555
  loadingText = "Adding...",
4556
4556
  successText = "Added!",
4557
+ errorText = "Couldn't add \u2014 try again",
4557
4558
  disabled = false,
4558
4559
  className = "",
4559
4560
  quantity = 1,
@@ -4563,8 +4564,10 @@ function AddToCart({
4563
4564
  }) {
4564
4565
  const context = useProduct();
4565
4566
  const shopContext = useShopOptional();
4566
- const [loading, setLoading] = useState12(false);
4567
- const [success, setSuccess] = useState12(false);
4567
+ const [status, setStatus] = useState12("idle");
4568
+ const [errorMessage, setErrorMessage] = useState12(null);
4569
+ const loading = status === "adding";
4570
+ const success = status === "added";
4568
4571
  useEffect12(() => {
4569
4572
  checkProviders(
4570
4573
  "AddToCart",
@@ -4587,7 +4590,8 @@ function AddToCart({
4587
4590
  const handleClick = async () => {
4588
4591
  if (isDisabled || !product) return;
4589
4592
  try {
4590
- setLoading(true);
4593
+ setStatus("adding");
4594
+ setErrorMessage(null);
4591
4595
  const cartDetail = createCartDetail({
4592
4596
  productId: product.id,
4593
4597
  quantity,
@@ -4598,20 +4602,23 @@ function AddToCart({
4598
4602
  if (!cartDetail) {
4599
4603
  throw new Error("Invalid selection - unable to create cart detail");
4600
4604
  }
4601
- await simulateCartOperation(simulateDelay);
4602
- onClick?.(cartDetail);
4603
- setSuccess(true);
4605
+ if (onClick) {
4606
+ await onClick(cartDetail);
4607
+ } else {
4608
+ await simulateCartOperation(simulateDelay);
4609
+ }
4610
+ setStatus("added");
4604
4611
  setTimeout(() => {
4605
- setSuccess(false);
4612
+ setStatus((s) => s === "added" ? "idle" : s);
4606
4613
  }, 2e3);
4607
4614
  } catch (error) {
4608
- onError?.(error);
4609
- console.error("Add to cart failed:", error);
4610
- } finally {
4611
- setLoading(false);
4615
+ const err = error instanceof Error ? error : new Error(String(error));
4616
+ setStatus("error");
4617
+ setErrorMessage(err.message);
4618
+ onError?.(err);
4612
4619
  }
4613
4620
  };
4614
- const buttonText = loading ? loadingText : success ? successText : text;
4621
+ const buttonText = loading ? loadingText : success ? successText : status === "error" ? errorText : text;
4615
4622
  const defaultStyles = "w-full bg-primary text-primary-foreground hover:bg-primary/90 px-6 py-3 rounded-button font-medium transition-colors";
4616
4623
  const buttonClasses = `
4617
4624
  ${defaultStyles}
@@ -4622,6 +4629,7 @@ function AddToCart({
4622
4629
  const getAriaLabel = () => {
4623
4630
  if (loading) return loadingText;
4624
4631
  if (success) return successText;
4632
+ if (status === "error") return `${errorText} - ${product?.name || "product"}`;
4625
4633
  if (!product) return text;
4626
4634
  return `${text} - ${product.name || "product"}`;
4627
4635
  };
@@ -4635,9 +4643,11 @@ function AddToCart({
4635
4643
  onClick: handleClick,
4636
4644
  "aria-label": getAriaLabel(),
4637
4645
  "aria-busy": loading,
4646
+ "data-add-to-cart": status,
4638
4647
  children: buttonText
4639
4648
  }
4640
- )
4649
+ ),
4650
+ status === "error" && errorMessage && /* @__PURE__ */ jsx42("p", { role: "alert", className: "mt-2 text-sm text-destructive", children: errorMessage })
4641
4651
  ] });
4642
4652
  }
4643
4653