@wix/headless-stores 0.0.10 → 0.0.12

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.
Files changed (133) hide show
  1. package/cjs/dist/enums/index.d.ts +2 -0
  2. package/cjs/dist/enums/index.js +18 -0
  3. package/cjs/dist/enums/social-platform-enums.d.ts +25 -0
  4. package/cjs/dist/enums/social-platform-enums.js +30 -0
  5. package/cjs/dist/enums/sort-enums.d.ts +17 -0
  6. package/cjs/dist/enums/sort-enums.js +21 -0
  7. package/cjs/dist/react/BuyNow.d.ts +2 -4
  8. package/cjs/dist/react/Category.d.ts +9 -11
  9. package/cjs/dist/react/Category.js +8 -23
  10. package/cjs/dist/react/Collection.d.ts +13 -3
  11. package/cjs/dist/react/Collection.js +30 -19
  12. package/cjs/dist/react/FilteredCollection.d.ts +46 -15
  13. package/cjs/dist/react/FilteredCollection.js +45 -12
  14. package/cjs/dist/react/PayNow.d.ts +2 -4
  15. package/cjs/dist/react/Product.d.ts +8 -35
  16. package/cjs/dist/react/Product.js +10 -31
  17. package/cjs/dist/react/ProductActions.d.ts +42 -0
  18. package/cjs/dist/react/ProductActions.js +83 -0
  19. package/cjs/dist/react/ProductModifiers.d.ts +16 -8
  20. package/cjs/dist/react/ProductModifiers.js +19 -10
  21. package/cjs/dist/react/ProductVariantSelector.d.ts +52 -68
  22. package/cjs/dist/react/ProductVariantSelector.js +58 -86
  23. package/cjs/dist/react/RelatedProducts.d.ts +8 -4
  24. package/cjs/dist/react/RelatedProducts.js +12 -7
  25. package/cjs/dist/react/SelectedVariant.d.ts +66 -0
  26. package/cjs/dist/react/SelectedVariant.js +52 -0
  27. package/cjs/dist/react/SocialSharing.d.ts +24 -30
  28. package/cjs/dist/react/SocialSharing.js +8 -2
  29. package/cjs/dist/react/Sort.d.ts +12 -15
  30. package/cjs/dist/react/Sort.js +11 -34
  31. package/cjs/dist/react/index.d.ts +11 -10
  32. package/cjs/dist/react/index.js +3 -2
  33. package/cjs/dist/services/buy-now-service.js +2 -2
  34. package/cjs/dist/services/catalog-options-service.d.ts +2 -2
  35. package/cjs/dist/services/catalog-options-service.js +39 -45
  36. package/cjs/dist/services/catalog-price-range-service.d.ts +2 -2
  37. package/cjs/dist/services/catalog-price-range-service.js +13 -11
  38. package/cjs/dist/services/category-service.d.ts +7 -6
  39. package/cjs/dist/services/category-service.js +15 -11
  40. package/cjs/dist/services/collection-service.d.ts +8 -8
  41. package/cjs/dist/services/collection-service.js +182 -67
  42. package/cjs/dist/services/filter-service.d.ts +1 -1
  43. package/cjs/dist/services/filter-service.js +15 -23
  44. package/cjs/dist/services/product-media-gallery-service.d.ts +3 -3
  45. package/cjs/dist/services/product-modifiers-service.d.ts +6 -8
  46. package/cjs/dist/services/product-modifiers-service.js +14 -7
  47. package/cjs/dist/services/product-service.d.ts +8 -7
  48. package/cjs/dist/services/product-service.js +36 -19
  49. package/cjs/dist/services/related-products-service.d.ts +4 -4
  50. package/cjs/dist/services/related-products-service.js +4 -4
  51. package/cjs/dist/services/selected-variant-service.d.ts +24 -16
  52. package/cjs/dist/services/selected-variant-service.js +271 -126
  53. package/cjs/dist/services/social-sharing-service.d.ts +2 -2
  54. package/cjs/dist/services/social-sharing-service.js +47 -63
  55. package/cjs/dist/services/sort-service.d.ts +3 -2
  56. package/cjs/dist/services/sort-service.js +8 -13
  57. package/dist/enums/index.d.ts +2 -0
  58. package/dist/enums/index.js +2 -0
  59. package/dist/enums/social-platform-enums.d.ts +25 -0
  60. package/dist/enums/social-platform-enums.js +27 -0
  61. package/dist/enums/sort-enums.d.ts +17 -0
  62. package/dist/enums/sort-enums.js +18 -0
  63. package/dist/react/BuyNow.d.ts +2 -4
  64. package/dist/react/Category.d.ts +9 -11
  65. package/dist/react/Category.js +10 -23
  66. package/dist/react/Collection.d.ts +13 -3
  67. package/dist/react/Collection.js +32 -21
  68. package/dist/react/FilteredCollection.d.ts +46 -15
  69. package/dist/react/FilteredCollection.js +49 -16
  70. package/dist/react/PayNow.d.ts +2 -4
  71. package/dist/react/Product.d.ts +8 -35
  72. package/dist/react/Product.js +11 -31
  73. package/dist/react/ProductActions.d.ts +42 -0
  74. package/dist/react/ProductActions.js +79 -0
  75. package/dist/react/ProductModifiers.d.ts +16 -8
  76. package/dist/react/ProductModifiers.js +22 -13
  77. package/dist/react/ProductVariantSelector.d.ts +52 -68
  78. package/dist/react/ProductVariantSelector.js +57 -84
  79. package/dist/react/RelatedProducts.d.ts +8 -4
  80. package/dist/react/RelatedProducts.js +15 -10
  81. package/dist/react/SelectedVariant.d.ts +66 -0
  82. package/dist/react/SelectedVariant.js +46 -0
  83. package/dist/react/SocialSharing.d.ts +24 -30
  84. package/dist/react/SocialSharing.js +11 -5
  85. package/dist/react/Sort.d.ts +12 -15
  86. package/dist/react/Sort.js +13 -34
  87. package/dist/react/index.d.ts +11 -10
  88. package/dist/react/index.js +11 -10
  89. package/dist/services/buy-now-service.js +2 -2
  90. package/dist/services/catalog-options-service.d.ts +2 -2
  91. package/dist/services/catalog-options-service.js +41 -47
  92. package/dist/services/catalog-price-range-service.d.ts +2 -2
  93. package/dist/services/catalog-price-range-service.js +15 -13
  94. package/dist/services/category-service.d.ts +7 -6
  95. package/dist/services/category-service.js +17 -13
  96. package/dist/services/collection-service.d.ts +8 -8
  97. package/dist/services/collection-service.js +188 -73
  98. package/dist/services/filter-service.d.ts +1 -1
  99. package/dist/services/filter-service.js +20 -28
  100. package/dist/services/product-media-gallery-service.d.ts +3 -3
  101. package/dist/services/product-modifiers-service.d.ts +6 -8
  102. package/dist/services/product-modifiers-service.js +16 -9
  103. package/dist/services/product-service.d.ts +8 -7
  104. package/dist/services/product-service.js +38 -21
  105. package/dist/services/related-products-service.d.ts +4 -4
  106. package/dist/services/related-products-service.js +6 -6
  107. package/dist/services/selected-variant-service.d.ts +24 -16
  108. package/dist/services/selected-variant-service.js +273 -127
  109. package/dist/services/social-sharing-service.d.ts +2 -2
  110. package/dist/services/social-sharing-service.js +49 -65
  111. package/dist/services/sort-service.d.ts +3 -2
  112. package/dist/services/sort-service.js +11 -16
  113. package/package.json +7 -1
  114. package/cjs/dist/react/ProductMediaGallery.d.ts +0 -128
  115. package/cjs/dist/react/ProductMediaGallery.js +0 -100
  116. package/dist/astro/BuyNowServiceContext.d.ts +0 -2
  117. package/dist/astro/BuyNowServiceContext.js +0 -6
  118. package/dist/astro/ManagerProviderContext.d.ts +0 -2
  119. package/dist/astro/ManagerProviderContext.js +0 -7
  120. package/dist/astro/withBuyButtonService.d.ts +0 -2
  121. package/dist/astro/withBuyButtonService.js +0 -16
  122. package/dist/react/CurrentCartServiceProvider.d.ts +0 -5
  123. package/dist/react/CurrentCartServiceProvider.js +0 -12
  124. package/dist/react/ProductMediaGallery.d.ts +0 -128
  125. package/dist/react/ProductMediaGallery.js +0 -92
  126. package/dist/react/VariantSelectorServiceProvider.d.ts +0 -7
  127. package/dist/react/VariantSelectorServiceProvider.js +0 -22
  128. package/dist/react/hookim/index.d.ts +0 -5
  129. package/dist/react/hookim/index.js +0 -22
  130. package/dist/services/CurrentCartService.d.ts +0 -18
  131. package/dist/services/CurrentCartService.js +0 -9
  132. package/dist/services/VariantSelectorServices.d.ts +0 -8
  133. package/dist/services/VariantSelectorServices.js +0 -20
@@ -0,0 +1,2 @@
1
+ export * from './sort-enums';
2
+ export * from './social-platform-enums';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./sort-enums"), exports);
18
+ __exportStar(require("./social-platform-enums"), exports);
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Business logic enums for social sharing platforms (headless layer)
3
+ */
4
+ /**
5
+ * Enum for social sharing platforms (business identifiers)
6
+ */
7
+ export declare enum SocialPlatform {
8
+ FACEBOOK = "facebook",
9
+ TWITTER = "twitter",
10
+ LINKEDIN = "linkedin",
11
+ WHATSAPP = "whatsapp",
12
+ EMAIL = "email",
13
+ CLIPBOARD = "clipboard",
14
+ NATIVE = "native"
15
+ }
16
+ /**
17
+ * Enum for social platform share URLs (business logic)
18
+ */
19
+ export declare enum SocialPlatformShareUrl {
20
+ FACEBOOK = "https://www.facebook.com/sharer/sharer.php",
21
+ TWITTER = "https://twitter.com/intent/tweet",
22
+ LINKEDIN = "https://www.linkedin.com/sharing/share-offsite/",
23
+ WHATSAPP = "https://wa.me/",
24
+ EMAIL = "mailto:"
25
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /**
3
+ * Business logic enums for social sharing platforms (headless layer)
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SocialPlatformShareUrl = exports.SocialPlatform = void 0;
7
+ /**
8
+ * Enum for social sharing platforms (business identifiers)
9
+ */
10
+ var SocialPlatform;
11
+ (function (SocialPlatform) {
12
+ SocialPlatform["FACEBOOK"] = "facebook";
13
+ SocialPlatform["TWITTER"] = "twitter";
14
+ SocialPlatform["LINKEDIN"] = "linkedin";
15
+ SocialPlatform["WHATSAPP"] = "whatsapp";
16
+ SocialPlatform["EMAIL"] = "email";
17
+ SocialPlatform["CLIPBOARD"] = "clipboard";
18
+ SocialPlatform["NATIVE"] = "native";
19
+ })(SocialPlatform || (exports.SocialPlatform = SocialPlatform = {}));
20
+ /**
21
+ * Enum for social platform share URLs (business logic)
22
+ */
23
+ var SocialPlatformShareUrl;
24
+ (function (SocialPlatformShareUrl) {
25
+ SocialPlatformShareUrl["FACEBOOK"] = "https://www.facebook.com/sharer/sharer.php";
26
+ SocialPlatformShareUrl["TWITTER"] = "https://twitter.com/intent/tweet";
27
+ SocialPlatformShareUrl["LINKEDIN"] = "https://www.linkedin.com/sharing/share-offsite/";
28
+ SocialPlatformShareUrl["WHATSAPP"] = "https://wa.me/";
29
+ SocialPlatformShareUrl["EMAIL"] = "mailto:";
30
+ })(SocialPlatformShareUrl || (exports.SocialPlatformShareUrl = SocialPlatformShareUrl = {}));
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Enum for sort types used in the store
3
+ * Note: Cannot use SDK SortType as it's for aggregations (COUNT/VALUE)
4
+ * while this enum represents user-facing sort options
5
+ */
6
+ export declare enum SortType {
7
+ NEWEST = "newest",
8
+ NAME_ASC = "name_asc",
9
+ NAME_DESC = "name_desc",
10
+ PRICE_ASC = "price_asc",
11
+ PRICE_DESC = "price_desc",
12
+ RECOMMENDED = "recommended"
13
+ }
14
+ /**
15
+ * Default sort type
16
+ */
17
+ export declare const DEFAULT_SORT_TYPE = SortType.NEWEST;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_SORT_TYPE = exports.SortType = void 0;
4
+ /**
5
+ * Enum for sort types used in the store
6
+ * Note: Cannot use SDK SortType as it's for aggregations (COUNT/VALUE)
7
+ * while this enum represents user-facing sort options
8
+ */
9
+ var SortType;
10
+ (function (SortType) {
11
+ SortType["NEWEST"] = "newest";
12
+ SortType["NAME_ASC"] = "name_asc";
13
+ SortType["NAME_DESC"] = "name_desc";
14
+ SortType["PRICE_ASC"] = "price_asc";
15
+ SortType["PRICE_DESC"] = "price_desc";
16
+ SortType["RECOMMENDED"] = "recommended";
17
+ })(SortType || (exports.SortType = SortType = {}));
18
+ /**
19
+ * Default sort type
20
+ */
21
+ exports.DEFAULT_SORT_TYPE = SortType.NEWEST;
@@ -1,4 +1,3 @@
1
- export type RedirectToCheckout = () => void;
2
1
  /**
3
2
  * Props passed to the render function of the BuyNow component
4
3
  */
@@ -8,7 +7,7 @@ export interface BuyNowRenderProps {
8
7
  /** The name of the product being purchased */
9
8
  productName: string;
10
9
  /** Function to redirect the user to the checkout page */
11
- redirectToCheckout: RedirectToCheckout;
10
+ redirectToCheckout: () => void;
12
11
  /** The error message if the buy now operation fails */
13
12
  error: string | null;
14
13
  /** The price of the product being purchased */
@@ -20,13 +19,12 @@ export interface BuyNowRenderProps {
20
19
  /** Whether the product is available for pre-order */
21
20
  preOrderAvailable: boolean;
22
21
  }
23
- export type BuyNowChildren = (props: BuyNowRenderProps) => React.ReactNode;
24
22
  /**
25
23
  * Props for the BuyNow component
26
24
  */
27
25
  export interface BuyNowProps {
28
26
  /** Render function that receives buy now state and actions */
29
- children: BuyNowChildren;
27
+ children: (props: BuyNowRenderProps) => React.ReactNode;
30
28
  }
31
29
  /**
32
30
  * A headless component that provides buy now functionality using the render props pattern.
@@ -1,17 +1,15 @@
1
- import React, { type ReactNode } from "react";
2
- import { type CategoryServiceAPI } from "../services/category-service";
3
- import { categories } from "@wix/categories";
4
- interface CategoryProviderProps {
5
- children: ReactNode;
6
- }
7
- export declare const Provider: React.FC<CategoryProviderProps>;
8
- export declare const useCategory: () => CategoryServiceAPI;
9
- interface CategoryListProps {
1
+ import { type Category } from '@wix/auto_sdk_categories_categories';
2
+ import React, { type ReactNode } from 'react';
3
+ export interface CategoryListProps {
10
4
  children: (data: {
11
- categories: categories.Category[];
5
+ categories: Category[];
12
6
  selectedCategory: string | null;
13
7
  setSelectedCategory: (categoryId: string | null) => void;
14
8
  }) => ReactNode;
15
9
  }
10
+ /**
11
+ * Headless component for displaying a list of categories
12
+ *
13
+ * @component
14
+ */
16
15
  export declare const List: React.FC<CategoryListProps>;
17
- export {};
@@ -1,33 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.List = exports.useCategory = exports.Provider = void 0;
3
+ exports.List = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
5
  const services_manager_react_1 = require("@wix/services-manager-react");
7
6
  const category_service_1 = require("../services/category-service");
8
- const CategoryContext = (0, react_1.createContext)(null);
9
- const Provider = ({ children, }) => {
10
- const service = (0, services_manager_react_1.useService)(category_service_1.CategoryServiceDefinition);
11
- return ((0, jsx_runtime_1.jsx)(CategoryContext.Provider, { value: service, children: children }));
12
- };
13
- exports.Provider = Provider;
14
- const useCategory = () => {
15
- const context = (0, react_1.useContext)(CategoryContext);
16
- if (!context) {
17
- throw new Error("useCategory must be used within a CategoryProvider");
18
- }
19
- return context;
20
- };
21
- exports.useCategory = useCategory;
7
+ /**
8
+ * Headless component for displaying a list of categories
9
+ *
10
+ * @component
11
+ */
22
12
  const List = ({ children }) => {
23
- const service = (0, exports.useCategory)();
24
- const [selectedCategory, setSelectedCategory] = (0, react_1.useState)(service.selectedCategory.get());
13
+ const service = (0, services_manager_react_1.useService)(category_service_1.CategoryServiceDefinition);
25
14
  const categories = service.categories.get();
26
- service.selectedCategory.subscribe((categoryId) => {
27
- if (categoryId !== selectedCategory) {
28
- setSelectedCategory(categoryId);
29
- }
30
- });
15
+ const selectedCategory = service.selectedCategory.get();
31
16
  return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
32
17
  selectedCategory,
33
18
  categories,
@@ -1,4 +1,4 @@
1
- import { productsV3 } from "@wix/stores";
1
+ import { type V3Product } from '@wix/auto_sdk_stores_products-v-3';
2
2
  /**
3
3
  * Props for Grid headless component
4
4
  */
@@ -11,7 +11,7 @@ export interface GridProps {
11
11
  */
12
12
  export interface GridRenderProps {
13
13
  /** Array of products */
14
- products: productsV3.V3Product[];
14
+ products: V3Product[];
15
15
  /** Whether products are loading */
16
16
  isLoading: boolean;
17
17
  /** Error message if any */
@@ -25,6 +25,8 @@ export interface GridRenderProps {
25
25
  }
26
26
  /**
27
27
  * Headless component for product grid
28
+ *
29
+ * @component
28
30
  */
29
31
  export declare const Grid: (props: GridProps) => import("react").ReactNode;
30
32
  /**
@@ -32,7 +34,7 @@ export declare const Grid: (props: GridProps) => import("react").ReactNode;
32
34
  */
33
35
  export interface ItemProps {
34
36
  /** Product data */
35
- product: productsV3.V3Product;
37
+ product: V3Product;
36
38
  /** Render prop function that receives product item data */
37
39
  children: (props: ItemRenderProps) => React.ReactNode;
38
40
  }
@@ -61,6 +63,8 @@ export interface ItemRenderProps {
61
63
  }
62
64
  /**
63
65
  * Headless component for individual product item
66
+ *
67
+ * @component
64
68
  */
65
69
  export declare const Item: (props: ItemProps) => import("react").ReactNode;
66
70
  /**
@@ -90,6 +94,8 @@ export interface LoadMoreRenderProps {
90
94
  /**
91
95
  * Headless component for load more products functionality
92
96
  * Note: V3 API uses simplified loading without traditional pagination
97
+ *
98
+ * @component
93
99
  */
94
100
  export declare const LoadMore: (props: LoadMoreProps) => import("react").ReactNode;
95
101
  /**
@@ -112,6 +118,8 @@ export interface HeaderRenderProps {
112
118
  }
113
119
  /**
114
120
  * Headless component for collection header with product count
121
+ *
122
+ * @component
115
123
  */
116
124
  export declare const Header: (props: HeaderProps) => import("react").ReactNode;
117
125
  /**
@@ -137,5 +145,7 @@ export interface ActionsRenderProps {
137
145
  /**
138
146
  * Headless component for collection actions (refresh, load more)
139
147
  * Replaces traditional pagination for V3 API
148
+ *
149
+ * @component
140
150
  */
141
151
  export declare const Actions: (props: ActionsProps) => import("react").ReactNode;
@@ -3,18 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Actions = exports.Header = exports.LoadMore = exports.Item = exports.Grid = void 0;
4
4
  const services_manager_react_1 = require("@wix/services-manager-react");
5
5
  const collection_service_1 = require("../services/collection-service");
6
+ const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
6
7
  /**
7
8
  * Headless component for product grid
9
+ *
10
+ * @component
8
11
  */
9
12
  const Grid = (props) => {
10
13
  const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
11
14
  // Debug logging to help identify service issues
12
15
  if (!service) {
13
- console.error("CollectionService is undefined");
16
+ console.error('CollectionService is undefined');
14
17
  return props.children({
15
18
  products: [],
16
19
  isLoading: false,
17
- error: "Service not available",
20
+ error: 'Service not available',
18
21
  isEmpty: true,
19
22
  totalProducts: 0,
20
23
  hasProducts: false,
@@ -37,11 +40,11 @@ const Grid = (props) => {
37
40
  });
38
41
  }
39
42
  catch (err) {
40
- console.error("Error accessing service properties:", err);
43
+ console.error('Error accessing service properties:', err);
41
44
  return props.children({
42
45
  products: [],
43
46
  isLoading: false,
44
- error: "Failed to load products",
47
+ error: 'Failed to load products',
45
48
  isEmpty: true,
46
49
  totalProducts: 0,
47
50
  hasProducts: false,
@@ -51,6 +54,8 @@ const Grid = (props) => {
51
54
  exports.Grid = Grid;
52
55
  /**
53
56
  * Headless component for individual product item
57
+ *
58
+ * @component
54
59
  */
55
60
  const Item = (props) => {
56
61
  const { product } = props;
@@ -59,18 +64,18 @@ const Item = (props) => {
59
64
  const image = product?.media?.main?.image || null;
60
65
  // Create formatted price since formattedAmount is not available
61
66
  const rawAmount = product.actualPriceRange?.minValue?.amount;
62
- const price = rawAmount ? `$${rawAmount}` : "$0.00";
67
+ const price = rawAmount ? `$${rawAmount}` : '$0.00';
63
68
  // Create formatted compare-at price
64
69
  const rawCompareAmount = product.compareAtPriceRange?.minValue?.amount;
65
70
  const compareAtPrice = rawCompareAmount ? `$${rawCompareAmount}` : null;
66
71
  const availabilityStatus = product.inventory?.availabilityStatus;
67
- const available = availabilityStatus === "IN_STOCK" ||
68
- availabilityStatus === "PARTIALLY_OUT_OF_STOCK";
69
- const description = typeof product.description === "string" ? product.description : "";
72
+ const available = availabilityStatus === auto_sdk_stores_products_v_3_1.InventoryAvailabilityStatus.IN_STOCK ||
73
+ availabilityStatus === auto_sdk_stores_products_v_3_1.InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK;
74
+ const description = typeof product.description === 'string' ? product.description : '';
70
75
  return props.children({
71
- id: product._id || "",
72
- title: product.name || "",
73
- slug: product.slug || "",
76
+ id: product._id || '',
77
+ title: product.name || '',
78
+ slug: product.slug || '',
74
79
  image,
75
80
  price,
76
81
  compareAtPrice,
@@ -83,12 +88,14 @@ exports.Item = Item;
83
88
  /**
84
89
  * Headless component for load more products functionality
85
90
  * Note: V3 API uses simplified loading without traditional pagination
91
+ *
92
+ * @component
86
93
  */
87
94
  const LoadMore = (props) => {
88
95
  const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
89
96
  // Error handling for undefined service
90
97
  if (!service) {
91
- console.error("CollectionService is undefined in LoadMore");
98
+ console.error('CollectionService is undefined in LoadMore');
92
99
  return props.children({
93
100
  loadMore: async () => { },
94
101
  refresh: async () => { },
@@ -113,7 +120,7 @@ const LoadMore = (props) => {
113
120
  });
114
121
  }
115
122
  catch (err) {
116
- console.error("Error in LoadMore:", err);
123
+ console.error('Error in LoadMore:', err);
117
124
  return props.children({
118
125
  loadMore: async () => { },
119
126
  refresh: async () => { },
@@ -127,12 +134,14 @@ const LoadMore = (props) => {
127
134
  exports.LoadMore = LoadMore;
128
135
  /**
129
136
  * Headless component for collection header with product count
137
+ *
138
+ * @component
130
139
  */
131
140
  const Header = (props) => {
132
141
  const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
133
142
  // Error handling for undefined service
134
143
  if (!service) {
135
- console.error("CollectionService is undefined in Header");
144
+ console.error('CollectionService is undefined in Header');
136
145
  return props.children({
137
146
  totalProducts: 0,
138
147
  isLoading: false,
@@ -150,7 +159,7 @@ const Header = (props) => {
150
159
  });
151
160
  }
152
161
  catch (err) {
153
- console.error("Error in Header:", err);
162
+ console.error('Error in Header:', err);
154
163
  return props.children({
155
164
  totalProducts: 0,
156
165
  isLoading: false,
@@ -162,17 +171,19 @@ exports.Header = Header;
162
171
  /**
163
172
  * Headless component for collection actions (refresh, load more)
164
173
  * Replaces traditional pagination for V3 API
174
+ *
175
+ * @component
165
176
  */
166
177
  const Actions = (props) => {
167
178
  const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
168
179
  // Error handling for undefined service
169
180
  if (!service) {
170
- console.error("CollectionService is undefined in Actions");
181
+ console.error('CollectionService is undefined in Actions');
171
182
  return props.children({
172
183
  refresh: async () => { },
173
184
  loadMore: async () => { },
174
185
  isLoading: false,
175
- error: "Service not available",
186
+ error: 'Service not available',
176
187
  });
177
188
  }
178
189
  try {
@@ -186,12 +197,12 @@ const Actions = (props) => {
186
197
  });
187
198
  }
188
199
  catch (err) {
189
- console.error("Error in Actions:", err);
200
+ console.error('Error in Actions:', err);
190
201
  return props.children({
191
202
  refresh: async () => { },
192
203
  loadMore: async () => { },
193
204
  isLoading: false,
194
- error: "Failed to load actions",
205
+ error: 'Failed to load actions',
195
206
  });
196
207
  }
197
208
  };
@@ -1,24 +1,35 @@
1
- import React, { type ReactNode } from "react";
2
- import { type AvailableOptions, type FilterServiceAPI, type Filter } from "../services/filter-service";
3
- import { productsV3 } from "@wix/stores";
4
- import { type CollectionServiceAPI } from "../services/collection-service";
5
- interface FilteredCollectionProviderProps {
1
+ import React, { type ReactNode } from 'react';
2
+ import { type AvailableOptions, type FilterServiceAPI, type Filter } from '../services/filter-service';
3
+ import { type V3Product } from '@wix/auto_sdk_stores_products-v-3';
4
+ import { type CollectionServiceAPI } from '../services/collection-service';
5
+ export type { AvailableOptions, Filter, FilterServiceAPI };
6
+ export interface FilteredCollectionProviderProps {
6
7
  children: ReactNode;
7
8
  }
9
+ /**
10
+ * Headless component for providing a filtered collection
11
+ *
12
+ * @component
13
+ */
8
14
  export declare const Provider: React.FC<FilteredCollectionProviderProps>;
9
15
  export declare const useFilteredCollection: () => {
10
16
  filter: FilterServiceAPI | null;
11
17
  collection: CollectionServiceAPI | null;
12
18
  };
13
- interface FiltersLoadingProps {
19
+ export interface FiltersLoadingProps {
14
20
  children: (data: {
15
21
  isFullyLoaded: boolean;
16
22
  }) => ReactNode;
17
23
  }
24
+ /**
25
+ * Headless component for displaying a loading state for filters
26
+ *
27
+ * @component
28
+ */
18
29
  export declare const FiltersLoading: React.FC<FiltersLoadingProps>;
19
- interface FilteredGridProps {
30
+ export interface FilteredGridProps {
20
31
  children: (data: {
21
- products: productsV3.V3Product[];
32
+ products: V3Product[];
22
33
  totalProducts: number;
23
34
  isLoading: boolean;
24
35
  error: string | null;
@@ -26,21 +37,32 @@ interface FilteredGridProps {
26
37
  hasMoreProducts: boolean;
27
38
  }) => ReactNode;
28
39
  }
40
+ /**
41
+ * Headless component for displaying a grid of filtered products
42
+ *
43
+ * @component
44
+ */
29
45
  export declare const Grid: React.FC<FilteredGridProps>;
30
- interface FilteredItemProps {
31
- product: productsV3.V3Product;
46
+ export interface FilteredItemProps {
47
+ product: V3Product;
32
48
  children: (data: {
33
49
  title: string;
34
50
  image: string | null;
51
+ imageAltText: string | null;
35
52
  price: string;
36
53
  compareAtPrice: string | null;
37
54
  available: boolean;
38
- href: string;
55
+ slug: string;
39
56
  description?: string;
40
57
  }) => ReactNode;
41
58
  }
59
+ /**
60
+ * Headless component for displaying an individual product item
61
+ *
62
+ * @component
63
+ */
42
64
  export declare const Item: React.FC<FilteredItemProps>;
43
- interface FilteredLoadMoreProps {
65
+ export interface FilteredLoadMoreProps {
44
66
  children: (data: {
45
67
  loadMore: () => Promise<void>;
46
68
  refresh: () => Promise<void>;
@@ -50,16 +72,25 @@ interface FilteredLoadMoreProps {
50
72
  hasMoreProducts: boolean;
51
73
  }) => ReactNode;
52
74
  }
75
+ /**
76
+ * Headless component for displaying a load more button
77
+ *
78
+ * @component
79
+ */
53
80
  export declare const LoadMore: React.FC<FilteredLoadMoreProps>;
54
- interface FilteredFiltersProps {
81
+ export interface FilteredFiltersProps {
55
82
  children: (data: {
56
83
  applyFilters: (filters: Filter) => void;
57
84
  clearFilters: () => void;
58
85
  currentFilters: Filter;
59
- allProducts: productsV3.V3Product[];
86
+ allProducts: V3Product[];
60
87
  availableOptions: AvailableOptions;
61
88
  isFiltered: boolean;
62
89
  }) => ReactNode;
63
90
  }
91
+ /**
92
+ * Headless component for displaying a filters component
93
+ *
94
+ * @component
95
+ */
64
96
  export declare const Filters: React.FC<FilteredFiltersProps>;
65
- export {};
@@ -5,9 +5,15 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const filter_service_1 = require("../services/filter-service");
7
7
  const services_manager_react_1 = require("@wix/services-manager-react");
8
+ const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
8
9
  const collection_service_1 = require("../services/collection-service");
9
10
  const FilteredCollectionContext = (0, react_1.createContext)({ filter: null, collection: null });
10
- const Provider = ({ children }) => {
11
+ /**
12
+ * Headless component for providing a filtered collection
13
+ *
14
+ * @component
15
+ */
16
+ const Provider = ({ children, }) => {
11
17
  const filter = (0, services_manager_react_1.useService)(filter_service_1.FilterServiceDefinition);
12
18
  const collection = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
13
19
  return ((0, jsx_runtime_1.jsx)(FilteredCollectionContext.Provider, { value: { filter, collection }, children: children }));
@@ -16,17 +22,27 @@ exports.Provider = Provider;
16
22
  const useFilteredCollection = () => {
17
23
  const context = (0, react_1.useContext)(FilteredCollectionContext);
18
24
  if (!context) {
19
- throw new Error("useFilteredCollection must be used within a FilteredCollectionProvider");
25
+ throw new Error('useFilteredCollection must be used within a FilteredCollectionProvider');
20
26
  }
21
27
  return context;
22
28
  };
23
29
  exports.useFilteredCollection = useFilteredCollection;
30
+ /**
31
+ * Headless component for displaying a loading state for filters
32
+ *
33
+ * @component
34
+ */
24
35
  const FiltersLoading = ({ children }) => {
25
36
  const { filter } = (0, exports.useFilteredCollection)();
26
37
  const isFullyLoaded = filter.isFullyLoaded.get();
27
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({ isFullyLoaded }) }));
38
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({ isFullyLoaded }) });
28
39
  };
29
40
  exports.FiltersLoading = FiltersLoading;
41
+ /**
42
+ * Headless component for displaying a grid of filtered products
43
+ *
44
+ * @component
45
+ */
30
46
  const Grid = ({ children }) => {
31
47
  const { collection } = (0, exports.useFilteredCollection)();
32
48
  const products = collection.products.get() || [];
@@ -45,39 +61,51 @@ const Grid = ({ children }) => {
45
61
  }) }));
46
62
  };
47
63
  exports.Grid = Grid;
48
- const Item = ({ product, children, }) => {
64
+ /**
65
+ * Headless component for displaying an individual product item
66
+ *
67
+ * @component
68
+ */
69
+ const Item = ({ product, children }) => {
49
70
  // Safe conversion of product data with type safety guards
50
- const title = String(product.name || "");
71
+ const title = String(product.name || '');
51
72
  const image = product.media?.main?.image || null;
73
+ const imageAltText = product.media?.main?.altText || '';
52
74
  const price = product.actualPriceRange?.minValue?.formattedAmount ||
53
75
  product.actualPriceRange?.maxValue?.formattedAmount ||
54
76
  (product.actualPriceRange?.minValue?.amount
55
77
  ? `$${product.actualPriceRange.minValue.amount}`
56
- : "$0.00");
78
+ : '$0.00');
57
79
  // Add compare at price
58
80
  const compareAtPrice = product.compareAtPriceRange?.minValue?.formattedAmount ||
59
81
  (product.compareAtPriceRange?.minValue?.amount
60
82
  ? `$${product.compareAtPriceRange.minValue.amount}`
61
83
  : null);
62
84
  const availabilityStatus = product.inventory?.availabilityStatus;
63
- const available = availabilityStatus === "IN_STOCK" ||
64
- availabilityStatus === "PARTIALLY_OUT_OF_STOCK";
65
- const href = `/store/products/${String(product.slug || product._id || "")}`;
85
+ const available = availabilityStatus === auto_sdk_stores_products_v_3_1.InventoryAvailabilityStatus.IN_STOCK ||
86
+ availabilityStatus === auto_sdk_stores_products_v_3_1.InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK;
87
+ const slug = String(product.slug || product._id || '');
66
88
  const description = product.plainDescription
67
89
  ? String(product.plainDescription)
68
90
  : undefined;
69
91
  return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
70
92
  title,
71
93
  image,
94
+ imageAltText,
72
95
  price: String(price),
73
96
  compareAtPrice,
74
97
  available,
75
- href,
98
+ slug,
76
99
  description,
77
100
  }) }));
78
101
  };
79
102
  exports.Item = Item;
80
- const LoadMore = ({ children, }) => {
103
+ /**
104
+ * Headless component for displaying a load more button
105
+ *
106
+ * @component
107
+ */
108
+ const LoadMore = ({ children }) => {
81
109
  const { collection } = (0, exports.useFilteredCollection)();
82
110
  const loadMore = collection.loadMore;
83
111
  const refresh = collection.refresh;
@@ -95,7 +123,12 @@ const LoadMore = ({ children, }) => {
95
123
  }) }));
96
124
  };
97
125
  exports.LoadMore = LoadMore;
98
- const Filters = ({ children, }) => {
126
+ /**
127
+ * Headless component for displaying a filters component
128
+ *
129
+ * @component
130
+ */
131
+ const Filters = ({ children }) => {
99
132
  const { collection, filter } = (0, exports.useFilteredCollection)();
100
133
  const applyFilters = filter.applyFilters;
101
134
  const clearFilters = filter.clearFilters;