@wix/headless-stores 0.0.36 → 0.0.38

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 (129) hide show
  1. package/cjs/dist/react/Category.d.ts +65 -59
  2. package/cjs/dist/react/Category.js +50 -83
  3. package/cjs/dist/react/CategoryList.d.ts +184 -0
  4. package/cjs/dist/react/CategoryList.js +174 -0
  5. package/cjs/dist/react/Product.d.ts +3 -3
  6. package/cjs/dist/react/Product.js +6 -6
  7. package/{dist/react/ProductsList.d.ts → cjs/dist/react/ProductList.d.ts} +71 -38
  8. package/cjs/dist/react/{ProductsList.js → ProductList.js} +30 -26
  9. package/cjs/dist/react/ProductListFilters.d.ts +244 -0
  10. package/cjs/dist/react/ProductListFilters.js +216 -0
  11. package/cjs/dist/react/ProductListPagination.d.ts +246 -0
  12. package/cjs/dist/react/ProductListPagination.js +207 -0
  13. package/cjs/dist/react/ProductListSort.d.ts +87 -0
  14. package/cjs/dist/react/ProductListSort.js +85 -0
  15. package/cjs/dist/react/ProductModifiers.d.ts +5 -5
  16. package/cjs/dist/react/ProductModifiers.js +10 -10
  17. package/cjs/dist/react/ProductVariantSelector.d.ts +5 -5
  18. package/cjs/dist/react/ProductVariantSelector.js +13 -10
  19. package/cjs/dist/react/SelectedVariant.d.ts +66 -3
  20. package/cjs/dist/react/SelectedVariant.js +106 -7
  21. package/cjs/dist/react/index.d.ts +6 -9
  22. package/cjs/dist/react/index.js +6 -9
  23. package/cjs/dist/services/buy-now-service.d.ts +208 -0
  24. package/cjs/dist/services/buy-now-service.js +132 -1
  25. package/cjs/dist/services/categories-list-service.d.ts +163 -0
  26. package/cjs/dist/services/categories-list-service.js +148 -0
  27. package/cjs/dist/services/category-service.d.ts +115 -70
  28. package/cjs/dist/services/category-service.js +101 -110
  29. package/cjs/dist/services/index.d.ts +6 -7
  30. package/cjs/dist/services/index.js +5 -16
  31. package/cjs/dist/services/pay-now-service.d.ts +146 -0
  32. package/cjs/dist/services/pay-now-service.js +112 -1
  33. package/cjs/dist/services/product-service.d.ts +71 -0
  34. package/cjs/dist/services/product-service.js +47 -0
  35. package/cjs/dist/services/products-list-filters-service.d.ts +292 -0
  36. package/cjs/dist/services/products-list-filters-service.js +446 -0
  37. package/cjs/dist/services/products-list-pagination-service.d.ts +186 -0
  38. package/cjs/dist/services/products-list-pagination-service.js +179 -0
  39. package/cjs/dist/services/products-list-service.d.ts +138 -52
  40. package/cjs/dist/services/products-list-service.js +185 -54
  41. package/cjs/dist/services/products-list-sort-service.d.ts +117 -0
  42. package/cjs/dist/services/products-list-sort-service.js +144 -0
  43. package/cjs/dist/utils/url-params.d.ts +68 -0
  44. package/cjs/dist/utils/url-params.js +72 -4
  45. package/dist/react/Category.d.ts +65 -59
  46. package/dist/react/Category.js +50 -83
  47. package/dist/react/CategoryList.d.ts +184 -0
  48. package/dist/react/CategoryList.js +174 -0
  49. package/dist/react/Product.d.ts +3 -3
  50. package/dist/react/Product.js +6 -6
  51. package/{cjs/dist/react/ProductsList.d.ts → dist/react/ProductList.d.ts} +71 -38
  52. package/dist/react/{ProductsList.js → ProductList.js} +30 -26
  53. package/dist/react/ProductListFilters.d.ts +244 -0
  54. package/dist/react/ProductListFilters.js +216 -0
  55. package/dist/react/ProductListPagination.d.ts +246 -0
  56. package/dist/react/ProductListPagination.js +207 -0
  57. package/dist/react/ProductListSort.d.ts +87 -0
  58. package/dist/react/ProductListSort.js +85 -0
  59. package/dist/react/ProductModifiers.d.ts +5 -5
  60. package/dist/react/ProductModifiers.js +10 -10
  61. package/dist/react/ProductVariantSelector.d.ts +5 -5
  62. package/dist/react/ProductVariantSelector.js +13 -10
  63. package/dist/react/SelectedVariant.d.ts +66 -3
  64. package/dist/react/SelectedVariant.js +106 -7
  65. package/dist/react/index.d.ts +6 -9
  66. package/dist/react/index.js +6 -9
  67. package/dist/services/buy-now-service.d.ts +208 -0
  68. package/dist/services/buy-now-service.js +132 -1
  69. package/dist/services/categories-list-service.d.ts +163 -0
  70. package/dist/services/categories-list-service.js +148 -0
  71. package/dist/services/category-service.d.ts +115 -70
  72. package/dist/services/category-service.js +101 -110
  73. package/dist/services/index.d.ts +6 -7
  74. package/dist/services/index.js +5 -16
  75. package/dist/services/pay-now-service.d.ts +146 -0
  76. package/dist/services/pay-now-service.js +112 -1
  77. package/dist/services/product-service.d.ts +71 -0
  78. package/dist/services/product-service.js +47 -0
  79. package/dist/services/products-list-filters-service.d.ts +292 -0
  80. package/dist/services/products-list-filters-service.js +446 -0
  81. package/dist/services/products-list-pagination-service.d.ts +186 -0
  82. package/dist/services/products-list-pagination-service.js +179 -0
  83. package/dist/services/products-list-service.d.ts +138 -52
  84. package/dist/services/products-list-service.js +185 -54
  85. package/dist/services/products-list-sort-service.d.ts +117 -0
  86. package/dist/services/products-list-sort-service.js +144 -0
  87. package/dist/utils/url-params.d.ts +68 -0
  88. package/dist/utils/url-params.js +72 -4
  89. package/package.json +3 -3
  90. package/cjs/dist/react/Collection.d.ts +0 -294
  91. package/cjs/dist/react/Collection.js +0 -345
  92. package/cjs/dist/react/FilteredCollection.d.ts +0 -299
  93. package/cjs/dist/react/FilteredCollection.js +0 -352
  94. package/cjs/dist/react/ProductActions.d.ts +0 -70
  95. package/cjs/dist/react/ProductActions.js +0 -104
  96. package/cjs/dist/react/RelatedProducts.d.ts +0 -169
  97. package/cjs/dist/react/RelatedProducts.js +0 -180
  98. package/cjs/dist/react/Sort.d.ts +0 -37
  99. package/cjs/dist/react/Sort.js +0 -36
  100. package/cjs/dist/services/catalog-service.d.ts +0 -36
  101. package/cjs/dist/services/catalog-service.js +0 -193
  102. package/cjs/dist/services/collection-service.d.ts +0 -124
  103. package/cjs/dist/services/collection-service.js +0 -628
  104. package/cjs/dist/services/filter-service.d.ts +0 -35
  105. package/cjs/dist/services/filter-service.js +0 -119
  106. package/cjs/dist/services/related-products-service.d.ts +0 -100
  107. package/cjs/dist/services/related-products-service.js +0 -127
  108. package/cjs/dist/services/sort-service.d.ts +0 -20
  109. package/cjs/dist/services/sort-service.js +0 -27
  110. package/dist/react/Collection.d.ts +0 -294
  111. package/dist/react/Collection.js +0 -345
  112. package/dist/react/FilteredCollection.d.ts +0 -299
  113. package/dist/react/FilteredCollection.js +0 -352
  114. package/dist/react/ProductActions.d.ts +0 -70
  115. package/dist/react/ProductActions.js +0 -104
  116. package/dist/react/RelatedProducts.d.ts +0 -169
  117. package/dist/react/RelatedProducts.js +0 -180
  118. package/dist/react/Sort.d.ts +0 -37
  119. package/dist/react/Sort.js +0 -36
  120. package/dist/services/catalog-service.d.ts +0 -36
  121. package/dist/services/catalog-service.js +0 -193
  122. package/dist/services/collection-service.d.ts +0 -124
  123. package/dist/services/collection-service.js +0 -628
  124. package/dist/services/filter-service.d.ts +0 -35
  125. package/dist/services/filter-service.js +0 -119
  126. package/dist/services/related-products-service.d.ts +0 -100
  127. package/dist/services/related-products-service.js +0 -127
  128. package/dist/services/sort-service.d.ts +0 -20
  129. package/dist/services/sort-service.js +0 -27
@@ -0,0 +1,179 @@
1
+ import { defineService } from "@wix/services-definitions";
2
+ import { implementService } from "@wix/services-definitions";
3
+ import { SignalsServiceDefinition, } from "@wix/services-definitions/core-services/signals";
4
+ import { ProductsListServiceDefinition } from "./products-list-service.js";
5
+ /**
6
+ * Service definition for the Products List Pagination service.
7
+ * This defines the reactive API contract for managing product list pagination state and navigation.
8
+ *
9
+ * @constant
10
+ */
11
+ export const ProductsListPaginationServiceDefinition = defineService("products-list-pagination");
12
+ /**
13
+ * Implementation of the Products List Pagination service that manages reactive pagination state.
14
+ * This service provides signals for pagination state and automatically updates the products list
15
+ * search options when pagination settings change. It supports both cursor-based pagination
16
+ * and load-more functionality.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * import { ProductsListPaginationService, ProductsListPaginationServiceDefinition } from '@wix/stores/services';
21
+ * import { useService } from '@wix/services-manager-react';
22
+ *
23
+ * function PaginationComponent() {
24
+ * return (
25
+ * <ServiceProvider services={createServicesMap([
26
+ * [ProductsListPaginationServiceDefinition, ProductsListPaginationService.withConfig({})]
27
+ * ])}>
28
+ * <PaginationControls />
29
+ * </ServiceProvider>
30
+ * );
31
+ * }
32
+ *
33
+ * function PaginationControls() {
34
+ * const paginationService = useService(ProductsListPaginationServiceDefinition);
35
+ * const currentLimit = paginationService.currentLimit.get();
36
+ * const hasNextPage = paginationService.hasNextPage.get();
37
+ * const hasPrevPage = paginationService.hasPrevPage.get();
38
+ *
39
+ * return (
40
+ * <div>
41
+ * <div>
42
+ * Items per page:
43
+ * <select
44
+ * value={currentLimit}
45
+ * onChange={(e) => paginationService.setLimit(parseInt(e.target.value))}
46
+ * >
47
+ * <option value={12}>12</option>
48
+ * <option value={24}>24</option>
49
+ * <option value={48}>48</option>
50
+ * </select>
51
+ * </div>
52
+ *
53
+ * <div>
54
+ * <button
55
+ * onClick={() => paginationService.goToFirstPage()}
56
+ * disabled={!hasPrevPage}
57
+ * >
58
+ * First
59
+ * </button>
60
+ * <button
61
+ * onClick={() => paginationService.prevPage()}
62
+ * disabled={!hasPrevPage}
63
+ * >
64
+ * Previous
65
+ * </button>
66
+ * <button
67
+ * onClick={() => paginationService.nextPage()}
68
+ * disabled={!hasNextPage}
69
+ * >
70
+ * Next
71
+ * </button>
72
+ * </div>
73
+ *
74
+ * <button onClick={() => paginationService.loadMore(12)}>
75
+ * Load More
76
+ * </button>
77
+ * </div>
78
+ * );
79
+ * }
80
+ * ```
81
+ */
82
+ export const ProductsListPaginationService = implementService.withConfig()(ProductsListPaginationServiceDefinition, ({ getService }) => {
83
+ let firstRun = true;
84
+ const signalsService = getService(SignalsServiceDefinition);
85
+ const productsListService = getService(ProductsListServiceDefinition);
86
+ const currentLimitSignal = signalsService.signal(getCurrentLimit(productsListService.searchOptions.get()));
87
+ const currentCursorSignal = signalsService.signal(getCurrentCursor(productsListService.searchOptions.get()));
88
+ // Computed signals derived from paging metadata
89
+ const hasNextPageSignal = signalsService.computed(() => {
90
+ const pagingMetadata = productsListService.pagingMetadata.get();
91
+ return pagingMetadata?.hasNext || false;
92
+ });
93
+ const hasPrevPageSignal = signalsService.computed(() => {
94
+ const pagingMetadata = productsListService.pagingMetadata.get();
95
+ return typeof pagingMetadata.cursors?.prev !== "undefined";
96
+ });
97
+ if (typeof window !== "undefined") {
98
+ // Watch for changes in pagination settings and update search options
99
+ signalsService.effect(() => {
100
+ // CRITICAL: Read the signals FIRST to establish dependencies, even on first run
101
+ const limit = currentLimitSignal.get();
102
+ const cursor = currentCursorSignal.get();
103
+ if (firstRun) {
104
+ firstRun = false;
105
+ return;
106
+ }
107
+ // Build new search options with updated pagination
108
+ const newSearchOptions = {
109
+ ...productsListService.searchOptions.peek(),
110
+ };
111
+ // Update cursor paging
112
+ if (limit > 0) {
113
+ newSearchOptions.cursorPaging = {
114
+ limit,
115
+ ...(cursor && { cursor }),
116
+ };
117
+ }
118
+ else {
119
+ delete newSearchOptions.cursorPaging;
120
+ }
121
+ // Use callback to update search options
122
+ productsListService.setSearchOptions(newSearchOptions);
123
+ });
124
+ }
125
+ return {
126
+ currentLimit: currentLimitSignal,
127
+ currentCursor: currentCursorSignal,
128
+ hasNextPage: hasNextPageSignal,
129
+ hasPrevPage: hasPrevPageSignal,
130
+ setLimit: (limit) => {
131
+ currentLimitSignal.set(limit);
132
+ // Reset pagination when changing page size
133
+ currentCursorSignal.set(null);
134
+ },
135
+ loadMore: (count) => {
136
+ const limit = currentLimitSignal.get();
137
+ currentLimitSignal.set(limit + count);
138
+ },
139
+ nextPage: () => {
140
+ const pagingMetadata = productsListService.pagingMetadata.get();
141
+ const nextCursor = pagingMetadata?.cursors?.next;
142
+ if (nextCursor) {
143
+ currentCursorSignal.set(nextCursor);
144
+ }
145
+ },
146
+ prevPage: () => {
147
+ const pagingMetadata = productsListService.pagingMetadata.get();
148
+ const previousCursor = pagingMetadata?.cursors?.prev;
149
+ if (previousCursor) {
150
+ currentCursorSignal.set(previousCursor);
151
+ }
152
+ },
153
+ goToFirstPage: () => {
154
+ currentCursorSignal.set(null);
155
+ },
156
+ };
157
+ });
158
+ /**
159
+ * Helper function to extract the current limit from search options.
160
+ * Returns the pagination limit or a default value of 100 if not specified.
161
+ *
162
+ * @private
163
+ * @param {Parameters<typeof productsV3.searchProducts>[0]} searchOptions - The search options object
164
+ * @returns {number} The current limit value
165
+ */
166
+ function getCurrentLimit(searchOptions) {
167
+ return searchOptions.cursorPaging?.limit || 100;
168
+ }
169
+ /**
170
+ * Helper function to extract the current cursor from search options.
171
+ * Returns the cursor string or null if not specified.
172
+ *
173
+ * @private
174
+ * @param {Parameters<typeof productsV3.searchProducts>[0]} searchOptions - The search options object
175
+ * @returns {string | null} The current cursor value or null
176
+ */
177
+ function getCurrentCursor(searchOptions) {
178
+ return searchOptions.cursorPaging?.cursor || null;
179
+ }
@@ -1,144 +1,230 @@
1
1
  import { type Signal } from "@wix/services-definitions/core-services/signals";
2
2
  import { productsV3 } from "@wix/stores";
3
- export interface ProductsListServiceConfig {
3
+ /**
4
+ * Configuration interface for the Products List service.
5
+ * Contains the initial products data, search options, and metadata.
6
+ *
7
+ * @interface ProductsListServiceConfig
8
+ */
9
+ export type ProductsListServiceConfig = {
10
+ /** Array of product objects to initialize the service with */
4
11
  products: productsV3.V3Product[];
12
+ /** Search options used to fetch the products */
5
13
  searchOptions: Parameters<typeof productsV3.searchProducts>[0];
14
+ /** Pagination metadata from the search response */
6
15
  pagingMetadata: productsV3.CommonCursorPagingMetadata;
16
+ /** Aggregation data containing filters, facets, and counts */
7
17
  aggregations: productsV3.AggregationData;
8
- }
18
+ };
9
19
  /**
10
- * Loads products list service configuration from the Wix Products API for SSR initialization.
20
+ * Loads products list service configuration from the Wix Stores API for SSR initialization.
11
21
  * This function is designed to be used during Server-Side Rendering (SSR) to preload
12
- * products based on search criteria that will be used to configure the ProductsListService.
22
+ * a list of products based on search criteria.
13
23
  *
14
- * @param searchOptions Search options for filtering and querying products
15
- * @returns Promise that resolves to ProductsListServiceConfig with products, metadata, and aggregations
24
+ * @param {Parameters<typeof productsV3.searchProducts>[0]} searchOptions - The search options for querying products
25
+ * @returns {Promise<ProductsListServiceConfig>} Promise that resolves to the products list configuration
16
26
  *
17
27
  * @example
18
28
  * ```astro
19
29
  * ---
20
- * // Astro page example - pages/search.astro
30
+ * // Astro page example - pages/products.astro
21
31
  * import { loadProductsListServiceConfig } from '@wix/stores/services';
22
- * import { ProductsList } from '@wix/stores/components';
23
- *
24
- * // Get search query from URL params
25
- * const searchQuery = Astro.url.searchParams.get('q') || '';
26
- * const category = Astro.url.searchParams.get('category');
32
+ * import { ProductList } from '@wix/stores/components';
27
33
  *
28
- * // Build search options
34
+ * // Define search options
29
35
  * const searchOptions = {
30
- * query: { search: searchQuery },
31
- * filter: category ? { categories: [category] } : undefined,
32
- * paging: { limit: 12 }
36
+ * cursorPaging: { limit: 12 },
37
+ * filter: {},
38
+ * sort: [{ fieldName: 'name', order: 'ASC' }]
33
39
  * };
34
40
  *
35
- * // Load products during SSR
36
- * const productsListConfig = await loadProductsListServiceConfig(searchOptions);
41
+ * // Load products data during SSR
42
+ * const productsConfig = await loadProductsListServiceConfig(searchOptions);
37
43
  * ---
38
44
  *
39
- * <ProductsList.Root productsListConfig={productsListConfig}>
40
- * <ProductsList.ItemContent>
45
+ * <ProductList.Root productsConfig={productsConfig}>
46
+ * <ProductList.ItemContent>
41
47
  * {({ product }) => (
42
- * <div class="product-item">
48
+ * <div>
43
49
  * <h3>{product.name}</h3>
50
+ * <p>{product.description}</p>
44
51
  * </div>
45
52
  * )}
46
- * </ProductsList.ItemContent>
47
- * </ProductsList.Root>
53
+ * </ProductList.ItemContent>
54
+ * </ProductList.Root>
48
55
  * ```
49
56
  *
50
57
  * @example
51
58
  * ```tsx
52
- * // Next.js page example - pages/search.tsx
59
+ * // Next.js page example - pages/products.tsx
53
60
  * import { GetServerSideProps } from 'next';
54
61
  * import { loadProductsListServiceConfig } from '@wix/stores/services';
55
62
  * import { ProductsList } from '@wix/stores/components';
56
63
  *
57
- * interface SearchPageProps {
58
- * productsListConfig: Awaited<ReturnType<typeof loadProductsListServiceConfig>>;
59
- * searchQuery: string;
64
+ * interface ProductsPageProps {
65
+ * productsConfig: Awaited<ReturnType<typeof loadProductsListServiceConfig>>;
60
66
  * }
61
67
  *
62
- * export const getServerSideProps: GetServerSideProps<SearchPageProps> = async ({ query }) => {
63
- * const searchQuery = (query.q as string) || '';
64
- * const category = query.category as string;
65
- *
66
- * // Build search options
68
+ * export const getServerSideProps: GetServerSideProps<ProductsPageProps> = async () => {
67
69
  * const searchOptions = {
68
- * query: { search: searchQuery },
69
- * filter: category ? { categories: [category] } : undefined,
70
- * paging: { limit: 12 }
70
+ * cursorPaging: { limit: 12 },
71
+ * filter: {},
72
+ * sort: [{ fieldName: 'name', order: 'ASC' }]
71
73
  * };
72
74
  *
73
- * // Load products during SSR
74
- * const productsListConfig = await loadProductsListServiceConfig(searchOptions);
75
+ * const productsConfig = await loadProductsListServiceConfig(searchOptions);
75
76
  *
76
77
  * return {
77
78
  * props: {
78
- * productsListConfig,
79
- * searchQuery,
79
+ * productsConfig,
80
80
  * },
81
81
  * };
82
82
  * };
83
83
  *
84
- * export default function SearchPage({ productsListConfig, searchQuery }: SearchPageProps) {
84
+ * export default function ProductsPage({ productsConfig }: ProductsPageProps) {
85
85
  * return (
86
- * <div>
87
- * <h1>Search Results for "{searchQuery}"</h1>
88
- * <ProductsList.Root productsListConfig={productsListConfig}>
89
- * <ProductsList.ItemContent>
90
- * {({ product }) => (
91
- * <div className="product-item">
92
- * <h3>{product.name}</h3>
93
- * </div>
94
- * )}
95
- * </ProductsList.ItemContent>
96
- * </ProductsList.Root>
97
- * </div>
86
+ * <ProductList.Root productsConfig={productsConfig}>
87
+ * <ProductList.ItemContent>
88
+ * {({ product }) => (
89
+ * <div>
90
+ * <h3>{product.name}</h3>
91
+ * <p>{product.description}</p>
92
+ * </div>
93
+ * )}
94
+ * </ProductList.ItemContent>
95
+ * </ProductList.Root>
98
96
  * );
99
97
  * }
100
98
  * ```
101
99
  */
102
100
  export declare function loadProductsListServiceConfig(searchOptions: Parameters<typeof productsV3.searchProducts>[0]): Promise<ProductsListServiceConfig>;
101
+ /**
102
+ * Service definition for the Products List service.
103
+ * This defines the reactive API contract for managing a list of products with search, pagination, and filtering capabilities.
104
+ *
105
+ * @constant
106
+ */
103
107
  export declare const ProductsListServiceDefinition: string & {
104
108
  __api: {
109
+ /** Reactive signal containing the list of products */
105
110
  products: Signal<productsV3.V3Product[]>;
111
+ /** Reactive signal containing aggregation data for filters and facets */
106
112
  aggregations: Signal<productsV3.AggregationData>;
113
+ /** Reactive signal containing pagination metadata */
107
114
  pagingMetadata: Signal<productsV3.CommonCursorPagingMetadata>;
115
+ /** Reactive signal containing current search options */
108
116
  searchOptions: Signal<Parameters<typeof productsV3.searchProducts>[0]>;
117
+ /** Reactive signal indicating if products are currently being loaded */
109
118
  isLoading: Signal<boolean>;
119
+ /** Reactive signal containing any error message, or null if no error */
110
120
  error: Signal<string | null>;
121
+ /** Function to update search options and trigger a new search */
111
122
  setSearchOptions: (searchOptions: Parameters<typeof productsV3.searchProducts>[0]) => void;
112
123
  };
113
124
  __config: ProductsListServiceConfig;
114
125
  isServiceDefinition?: boolean;
115
126
  } & {
127
+ /** Reactive signal containing the list of products */
116
128
  products: Signal<productsV3.V3Product[]>;
129
+ /** Reactive signal containing aggregation data for filters and facets */
117
130
  aggregations: Signal<productsV3.AggregationData>;
131
+ /** Reactive signal containing pagination metadata */
118
132
  pagingMetadata: Signal<productsV3.CommonCursorPagingMetadata>;
133
+ /** Reactive signal containing current search options */
119
134
  searchOptions: Signal<Parameters<typeof productsV3.searchProducts>[0]>;
135
+ /** Reactive signal indicating if products are currently being loaded */
120
136
  isLoading: Signal<boolean>;
137
+ /** Reactive signal containing any error message, or null if no error */
121
138
  error: Signal<string | null>;
139
+ /** Function to update search options and trigger a new search */
122
140
  setSearchOptions: (searchOptions: Parameters<typeof productsV3.searchProducts>[0]) => void;
123
141
  };
142
+ /**
143
+ * Implementation of the Products List service that manages reactive products data.
144
+ * This service provides signals for products data, search options, pagination, aggregations,
145
+ * loading state, and error handling. It automatically re-fetches products when search options change.
146
+ *
147
+ * @example
148
+ * ```tsx
149
+ * import { ProductListService, ProductsListServiceDefinition } from '@wix/stores/services';
150
+ * import { useService } from '@wix/services-manager-react';
151
+ *
152
+ * function ProductsComponent({ productsConfig }) {
153
+ * return (
154
+ * <ServiceProvider services={createServicesMap([
155
+ * [ProductsListServiceDefinition, ProductListService.withConfig(productsConfig)]
156
+ * ])}>
157
+ * <ProductsDisplay />
158
+ * </ServiceProvider>
159
+ * );
160
+ * }
161
+ *
162
+ * function ProductsDisplay() {
163
+ * const productsService = useService(ProductsListServiceDefinition);
164
+ * const products = productsService.products.get();
165
+ * const isLoading = productsService.isLoading.get();
166
+ * const error = productsService.error.get();
167
+ *
168
+ * // Update search options to filter by category
169
+ * const filterByCategory = (categoryId: string) => {
170
+ * const currentOptions = productsService.searchOptions.get();
171
+ * productsService.setSearchOptions({
172
+ * ...currentOptions,
173
+ * filter: {
174
+ * ...currentOptions.filter,
175
+ * categoryIds: [categoryId]
176
+ * }
177
+ * });
178
+ * };
179
+ *
180
+ * if (isLoading) return <div>Loading products...</div>;
181
+ * if (error) return <div>Error: {error}</div>;
182
+ *
183
+ * return (
184
+ * <div>
185
+ * {products.map(product => (
186
+ * <div key={product._id}>
187
+ * <h3>{product.name}</h3>
188
+ * <p>{product.description}</p>
189
+ * </div>
190
+ * ))}
191
+ * </div>
192
+ * );
193
+ * }
194
+ * ```
195
+ */
124
196
  export declare const ProductListService: import("@wix/services-definitions").ServiceFactory<string & {
125
197
  __api: {
198
+ /** Reactive signal containing the list of products */
126
199
  products: Signal<productsV3.V3Product[]>;
200
+ /** Reactive signal containing aggregation data for filters and facets */
127
201
  aggregations: Signal<productsV3.AggregationData>;
202
+ /** Reactive signal containing pagination metadata */
128
203
  pagingMetadata: Signal<productsV3.CommonCursorPagingMetadata>;
204
+ /** Reactive signal containing current search options */
129
205
  searchOptions: Signal<Parameters<typeof productsV3.searchProducts>[0]>;
206
+ /** Reactive signal indicating if products are currently being loaded */
130
207
  isLoading: Signal<boolean>;
208
+ /** Reactive signal containing any error message, or null if no error */
131
209
  error: Signal<string | null>;
210
+ /** Function to update search options and trigger a new search */
132
211
  setSearchOptions: (searchOptions: Parameters<typeof productsV3.searchProducts>[0]) => void;
133
212
  };
134
213
  __config: ProductsListServiceConfig;
135
214
  isServiceDefinition?: boolean;
136
215
  } & {
216
+ /** Reactive signal containing the list of products */
137
217
  products: Signal<productsV3.V3Product[]>;
218
+ /** Reactive signal containing aggregation data for filters and facets */
138
219
  aggregations: Signal<productsV3.AggregationData>;
220
+ /** Reactive signal containing pagination metadata */
139
221
  pagingMetadata: Signal<productsV3.CommonCursorPagingMetadata>;
222
+ /** Reactive signal containing current search options */
140
223
  searchOptions: Signal<Parameters<typeof productsV3.searchProducts>[0]>;
224
+ /** Reactive signal indicating if products are currently being loaded */
141
225
  isLoading: Signal<boolean>;
226
+ /** Reactive signal containing any error message, or null if no error */
142
227
  error: Signal<string | null>;
228
+ /** Function to update search options and trigger a new search */
143
229
  setSearchOptions: (searchOptions: Parameters<typeof productsV3.searchProducts>[0]) => void;
144
230
  }, ProductsListServiceConfig>;