@wix/headless-stores 0.0.35 → 0.0.37

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 (131) hide show
  1. package/cjs/dist/react/Category.d.ts +83 -31
  2. package/cjs/dist/react/Category.js +68 -35
  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/cjs/dist/react/ProductActions.d.ts +1 -1
  8. package/cjs/dist/react/ProductActions.js +2 -2
  9. package/{dist/react/ProductsList.d.ts → cjs/dist/react/ProductList.d.ts} +71 -38
  10. package/{dist/react/ProductsList.js → cjs/dist/react/ProductList.js} +30 -26
  11. package/cjs/dist/react/ProductListFilters.d.ts +244 -0
  12. package/cjs/dist/react/ProductListFilters.js +216 -0
  13. package/cjs/dist/react/ProductListPagination.d.ts +246 -0
  14. package/cjs/dist/react/ProductListPagination.js +207 -0
  15. package/cjs/dist/react/ProductListSort.d.ts +87 -0
  16. package/cjs/dist/react/ProductListSort.js +85 -0
  17. package/cjs/dist/react/ProductModifiers.d.ts +5 -5
  18. package/cjs/dist/react/ProductModifiers.js +10 -10
  19. package/cjs/dist/react/ProductVariantSelector.d.ts +5 -5
  20. package/cjs/dist/react/ProductVariantSelector.js +13 -10
  21. package/cjs/dist/react/SelectedVariant.d.ts +3 -3
  22. package/cjs/dist/react/SelectedVariant.js +6 -6
  23. package/cjs/dist/react/index.d.ts +7 -9
  24. package/cjs/dist/react/index.js +7 -9
  25. package/cjs/dist/services/buy-now-service.d.ts +208 -0
  26. package/cjs/dist/services/buy-now-service.js +132 -1
  27. package/cjs/dist/services/categories-list-service.d.ts +163 -0
  28. package/cjs/dist/services/categories-list-service.js +148 -0
  29. package/cjs/dist/services/category-service.d.ts +115 -70
  30. package/cjs/dist/services/category-service.js +101 -110
  31. package/cjs/dist/services/index.d.ts +6 -7
  32. package/cjs/dist/services/index.js +5 -16
  33. package/cjs/dist/services/pay-now-service.d.ts +146 -0
  34. package/cjs/dist/services/pay-now-service.js +112 -1
  35. package/cjs/dist/services/product-service.d.ts +71 -0
  36. package/cjs/dist/services/product-service.js +47 -0
  37. package/cjs/dist/services/products-list-filters-service.d.ts +292 -0
  38. package/cjs/dist/services/products-list-filters-service.js +446 -0
  39. package/cjs/dist/services/products-list-pagination-service.d.ts +186 -0
  40. package/cjs/dist/services/products-list-pagination-service.js +179 -0
  41. package/cjs/dist/services/products-list-service.d.ts +138 -52
  42. package/cjs/dist/services/products-list-service.js +98 -51
  43. package/cjs/dist/services/products-list-sort-service.d.ts +117 -0
  44. package/cjs/dist/services/products-list-sort-service.js +144 -0
  45. package/cjs/dist/services/selected-variant-service.js +0 -1
  46. package/cjs/dist/utils/url-params.d.ts +68 -0
  47. package/cjs/dist/utils/url-params.js +72 -4
  48. package/dist/react/Category.d.ts +83 -31
  49. package/dist/react/Category.js +68 -35
  50. package/dist/react/CategoryList.d.ts +184 -0
  51. package/dist/react/CategoryList.js +174 -0
  52. package/dist/react/Product.d.ts +3 -3
  53. package/dist/react/Product.js +6 -6
  54. package/dist/react/ProductActions.d.ts +1 -1
  55. package/dist/react/ProductActions.js +2 -2
  56. package/{cjs/dist/react/ProductsList.d.ts → dist/react/ProductList.d.ts} +71 -38
  57. package/{cjs/dist/react/ProductsList.js → dist/react/ProductList.js} +30 -26
  58. package/dist/react/ProductListFilters.d.ts +244 -0
  59. package/dist/react/ProductListFilters.js +216 -0
  60. package/dist/react/ProductListPagination.d.ts +246 -0
  61. package/dist/react/ProductListPagination.js +207 -0
  62. package/dist/react/ProductListSort.d.ts +87 -0
  63. package/dist/react/ProductListSort.js +85 -0
  64. package/dist/react/ProductModifiers.d.ts +5 -5
  65. package/dist/react/ProductModifiers.js +10 -10
  66. package/dist/react/ProductVariantSelector.d.ts +5 -5
  67. package/dist/react/ProductVariantSelector.js +13 -10
  68. package/dist/react/SelectedVariant.d.ts +3 -3
  69. package/dist/react/SelectedVariant.js +6 -6
  70. package/dist/react/index.d.ts +7 -9
  71. package/dist/react/index.js +7 -9
  72. package/dist/services/buy-now-service.d.ts +208 -0
  73. package/dist/services/buy-now-service.js +132 -1
  74. package/dist/services/categories-list-service.d.ts +163 -0
  75. package/dist/services/categories-list-service.js +148 -0
  76. package/dist/services/category-service.d.ts +115 -70
  77. package/dist/services/category-service.js +101 -110
  78. package/dist/services/index.d.ts +6 -7
  79. package/dist/services/index.js +5 -16
  80. package/dist/services/pay-now-service.d.ts +146 -0
  81. package/dist/services/pay-now-service.js +112 -1
  82. package/dist/services/product-service.d.ts +71 -0
  83. package/dist/services/product-service.js +47 -0
  84. package/dist/services/products-list-filters-service.d.ts +292 -0
  85. package/dist/services/products-list-filters-service.js +446 -0
  86. package/dist/services/products-list-pagination-service.d.ts +186 -0
  87. package/dist/services/products-list-pagination-service.js +179 -0
  88. package/dist/services/products-list-service.d.ts +138 -52
  89. package/dist/services/products-list-service.js +98 -51
  90. package/dist/services/products-list-sort-service.d.ts +117 -0
  91. package/dist/services/products-list-sort-service.js +144 -0
  92. package/dist/services/selected-variant-service.js +0 -1
  93. package/dist/utils/url-params.d.ts +68 -0
  94. package/dist/utils/url-params.js +72 -4
  95. package/package.json +3 -3
  96. package/cjs/dist/react/Collection.d.ts +0 -294
  97. package/cjs/dist/react/Collection.js +0 -345
  98. package/cjs/dist/react/FilteredCollection.d.ts +0 -216
  99. package/cjs/dist/react/FilteredCollection.js +0 -256
  100. package/cjs/dist/react/RelatedProducts.d.ts +0 -169
  101. package/cjs/dist/react/RelatedProducts.js +0 -180
  102. package/cjs/dist/react/Sort.d.ts +0 -37
  103. package/cjs/dist/react/Sort.js +0 -36
  104. package/cjs/dist/services/catalog-service.d.ts +0 -36
  105. package/cjs/dist/services/catalog-service.js +0 -193
  106. package/cjs/dist/services/collection-service.d.ts +0 -124
  107. package/cjs/dist/services/collection-service.js +0 -628
  108. package/cjs/dist/services/filter-service.d.ts +0 -35
  109. package/cjs/dist/services/filter-service.js +0 -119
  110. package/cjs/dist/services/related-products-service.d.ts +0 -100
  111. package/cjs/dist/services/related-products-service.js +0 -127
  112. package/cjs/dist/services/sort-service.d.ts +0 -20
  113. package/cjs/dist/services/sort-service.js +0 -27
  114. package/dist/react/Collection.d.ts +0 -294
  115. package/dist/react/Collection.js +0 -345
  116. package/dist/react/FilteredCollection.d.ts +0 -216
  117. package/dist/react/FilteredCollection.js +0 -256
  118. package/dist/react/RelatedProducts.d.ts +0 -169
  119. package/dist/react/RelatedProducts.js +0 -180
  120. package/dist/react/Sort.d.ts +0 -37
  121. package/dist/react/Sort.js +0 -36
  122. package/dist/services/catalog-service.d.ts +0 -36
  123. package/dist/services/catalog-service.js +0 -193
  124. package/dist/services/collection-service.d.ts +0 -124
  125. package/dist/services/collection-service.js +0 -628
  126. package/dist/services/filter-service.d.ts +0 -35
  127. package/dist/services/filter-service.js +0 -119
  128. package/dist/services/related-products-service.d.ts +0 -100
  129. package/dist/services/related-products-service.js +0 -127
  130. package/dist/services/sort-service.d.ts +0 -20
  131. package/dist/services/sort-service.js +0 -27
@@ -0,0 +1,292 @@
1
+ import { type Signal } from "@wix/services-definitions/core-services/signals";
2
+ import { customizationsV3 } from "@wix/stores";
3
+ /**
4
+ * Interface representing a product option (like Size, Color, etc.).
5
+ * Contains the option metadata and available choices.
6
+ *
7
+ * @interface ProductOption
8
+ */
9
+ export interface ProductOption {
10
+ /** Unique identifier for the product option */
11
+ id: string;
12
+ /** Display name of the option (e.g., "Size", "Color") */
13
+ name: string;
14
+ /** Array of available choices for this option */
15
+ choices: ProductChoice[];
16
+ /** Optional render type for UI display purposes */
17
+ optionRenderType?: string;
18
+ }
19
+ /**
20
+ * Interface representing a choice within a product option.
21
+ * For example, "Red" would be a choice within a "Color" option.
22
+ *
23
+ * @interface ProductChoice
24
+ */
25
+ export interface ProductChoice {
26
+ /** Unique identifier for the choice */
27
+ id: string;
28
+ /** Display name of the choice (e.g., "Red", "Large") */
29
+ name: string;
30
+ /** Optional color code for color-based choices */
31
+ colorCode?: string;
32
+ }
33
+ /**
34
+ * Enumeration of inventory status types available for filtering.
35
+ * Maps to the Wix Stores API inventory availability statuses.
36
+ *
37
+ * @enum {string}
38
+ */
39
+ export declare enum InventoryStatusType {
40
+ /** Product is in stock and available for purchase */
41
+ IN_STOCK = "IN_STOCK",
42
+ /** Product is out of stock */
43
+ OUT_OF_STOCK = "OUT_OF_STOCK",
44
+ /** Product is partially out of stock (some variants available) */
45
+ PARTIALLY_OUT_OF_STOCK = "PARTIALLY_OUT_OF_STOCK"
46
+ }
47
+ /**
48
+ * Configuration interface for the Products List Filters service.
49
+ * Contains customizations data used to build filter options.
50
+ *
51
+ * @interface ProductsListFiltersServiceConfig
52
+ */
53
+ export type ProductsListFiltersServiceConfig = {
54
+ /** Array of product customizations for building filter options */
55
+ customizations: customizationsV3.Customization[];
56
+ };
57
+ /**
58
+ * Loads products list filters service configuration from the Wix Stores API for SSR initialization.
59
+ * This function fetches customization data that will be used to build product filter options.
60
+ *
61
+ * @returns {Promise<ProductsListFiltersServiceConfig>} Promise that resolves to the filters configuration
62
+ *
63
+ * @example
64
+ * ```astro
65
+ * ---
66
+ * // Astro page example - pages/products.astro
67
+ * import { loadProductsListFiltersServiceConfig } from '@wix/stores/services';
68
+ * import { ProductsListFilters } from '@wix/stores/components';
69
+ *
70
+ * // Load filters configuration during SSR
71
+ * const filtersConfig = await loadProductsListFiltersServiceConfig();
72
+ * ---
73
+ *
74
+ * <ProductsListFilters.Root filtersConfig={filtersConfig}>
75
+ * <ProductsListFilters.MinPrice>
76
+ * {({ minPrice, setMinPrice }) => (
77
+ * <input
78
+ * type="number"
79
+ * value={minPrice}
80
+ * onChange={(e) => setMinPrice(parseFloat(e.target.value))}
81
+ * placeholder="Min Price"
82
+ * />
83
+ * )}
84
+ * </ProductsListFilters.MinPrice>
85
+ * </ProductsListFilters.Root>
86
+ * ```
87
+ *
88
+ * @example
89
+ * ```tsx
90
+ * // Next.js page example
91
+ * import { GetServerSideProps } from 'next';
92
+ * import { loadProductsListFiltersServiceConfig } from '@wix/stores/services';
93
+ *
94
+ * export const getServerSideProps: GetServerSideProps = async () => {
95
+ * const filtersConfig = await loadProductsListFiltersServiceConfig();
96
+ *
97
+ * return {
98
+ * props: {
99
+ * filtersConfig,
100
+ * },
101
+ * };
102
+ * };
103
+ * ```
104
+ */
105
+ export declare function loadProductsListFiltersServiceConfig(): Promise<ProductsListFiltersServiceConfig>;
106
+ /**
107
+ * Service definition for the Products List Filters service.
108
+ * This defines the reactive API contract for managing product list filtering capabilities
109
+ * including price, inventory status, and product option filters.
110
+ *
111
+ * @constant
112
+ */
113
+ export declare const ProductsListFiltersServiceDefinition: string & {
114
+ __api: {
115
+ /** Reactive signal containing the minimum price filter value */
116
+ minPrice: Signal<number>;
117
+ /** Reactive signal containing the maximum price filter value */
118
+ maxPrice: Signal<number>;
119
+ /** Reactive signal containing available inventory status options */
120
+ availableInventoryStatuses: Signal<InventoryStatusType[]>;
121
+ /** Reactive signal containing selected inventory status filters */
122
+ selectedInventoryStatuses: Signal<InventoryStatusType[]>;
123
+ /** Reactive signal containing available product options for filtering */
124
+ availableProductOptions: Signal<ProductOption[]>;
125
+ /** Reactive signal containing selected product option filters */
126
+ selectedProductOptions: Signal<Record<string, string[]>>;
127
+ /** Function to set the minimum price filter */
128
+ setMinPrice: (minPrice: number) => void;
129
+ /** Function to set the maximum price filter */
130
+ setMaxPrice: (maxPrice: number) => void;
131
+ /** Function to toggle an inventory status filter */
132
+ toggleInventoryStatus: (status: InventoryStatusType) => void;
133
+ /** Function to toggle a product option choice filter */
134
+ toggleProductOption: (optionId: string, choiceId: string) => void;
135
+ /** Reactive signal indicating if any filters are currently applied */
136
+ isFiltered: Signal<boolean>;
137
+ /** Function to reset all filters to their default state */
138
+ reset: () => void;
139
+ };
140
+ __config: {};
141
+ isServiceDefinition?: boolean;
142
+ } & {
143
+ /** Reactive signal containing the minimum price filter value */
144
+ minPrice: Signal<number>;
145
+ /** Reactive signal containing the maximum price filter value */
146
+ maxPrice: Signal<number>;
147
+ /** Reactive signal containing available inventory status options */
148
+ availableInventoryStatuses: Signal<InventoryStatusType[]>;
149
+ /** Reactive signal containing selected inventory status filters */
150
+ selectedInventoryStatuses: Signal<InventoryStatusType[]>;
151
+ /** Reactive signal containing available product options for filtering */
152
+ availableProductOptions: Signal<ProductOption[]>;
153
+ /** Reactive signal containing selected product option filters */
154
+ selectedProductOptions: Signal<Record<string, string[]>>;
155
+ /** Function to set the minimum price filter */
156
+ setMinPrice: (minPrice: number) => void;
157
+ /** Function to set the maximum price filter */
158
+ setMaxPrice: (maxPrice: number) => void;
159
+ /** Function to toggle an inventory status filter */
160
+ toggleInventoryStatus: (status: InventoryStatusType) => void;
161
+ /** Function to toggle a product option choice filter */
162
+ toggleProductOption: (optionId: string, choiceId: string) => void;
163
+ /** Reactive signal indicating if any filters are currently applied */
164
+ isFiltered: Signal<boolean>;
165
+ /** Function to reset all filters to their default state */
166
+ reset: () => void;
167
+ };
168
+ /**
169
+ * Implementation of the Products List Filters service that manages reactive filtering state.
170
+ * This service provides signals for all filter types (price, inventory, product options) and
171
+ * automatically updates the products list search options when filters change.
172
+ *
173
+ * @example
174
+ * ```tsx
175
+ * import { ProductsListFiltersService, ProductsListFiltersServiceDefinition } from '@wix/stores/services';
176
+ * import { useService } from '@wix/services-manager-react';
177
+ *
178
+ * function FiltersComponent({ filtersConfig }) {
179
+ * return (
180
+ * <ServiceProvider services={createServicesMap([
181
+ * [ProductsListFiltersServiceDefinition, ProductsListFiltersService.withConfig(filtersConfig)]
182
+ * ])}>
183
+ * <FilterControls />
184
+ * </ServiceProvider>
185
+ * );
186
+ * }
187
+ *
188
+ * function FilterControls() {
189
+ * const filtersService = useService(ProductsListFiltersServiceDefinition);
190
+ * const minPrice = filtersService.minPrice.get();
191
+ * const maxPrice = filtersService.maxPrice.get();
192
+ * const selectedInventoryStatuses = filtersService.selectedInventoryStatuses.get();
193
+ * const availableProductOptions = filtersService.availableProductOptions.get();
194
+ * const isFiltered = filtersService.isFiltered.get();
195
+ *
196
+ * return (
197
+ * <div>
198
+ * <div>
199
+ * <input
200
+ * type="number"
201
+ * value={minPrice}
202
+ * onChange={(e) => filtersService.setMinPrice(parseFloat(e.target.value))}
203
+ * placeholder="Min Price"
204
+ * />
205
+ * <input
206
+ * type="number"
207
+ * value={maxPrice}
208
+ * onChange={(e) => filtersService.setMaxPrice(parseFloat(e.target.value))}
209
+ * placeholder="Max Price"
210
+ * />
211
+ * </div>
212
+ *
213
+ * {availableProductOptions.map(option => (
214
+ * <div key={option.id}>
215
+ * <h4>{option.name}</h4>
216
+ * {option.choices.map(choice => (
217
+ * <label key={choice.id}>
218
+ * <input
219
+ * type="checkbox"
220
+ * onChange={() => filtersService.toggleProductOption(option.id, choice.id)}
221
+ * />
222
+ * {choice.name}
223
+ * </label>
224
+ * ))}
225
+ * </div>
226
+ * ))}
227
+ *
228
+ * {isFiltered && (
229
+ * <button onClick={() => filtersService.reset()}>
230
+ * Clear All Filters
231
+ * </button>
232
+ * )}
233
+ * </div>
234
+ * );
235
+ * }
236
+ * ```
237
+ */
238
+ export declare const ProductsListFiltersService: import("@wix/services-definitions").ServiceFactory<string & {
239
+ __api: {
240
+ /** Reactive signal containing the minimum price filter value */
241
+ minPrice: Signal<number>;
242
+ /** Reactive signal containing the maximum price filter value */
243
+ maxPrice: Signal<number>;
244
+ /** Reactive signal containing available inventory status options */
245
+ availableInventoryStatuses: Signal<InventoryStatusType[]>;
246
+ /** Reactive signal containing selected inventory status filters */
247
+ selectedInventoryStatuses: Signal<InventoryStatusType[]>;
248
+ /** Reactive signal containing available product options for filtering */
249
+ availableProductOptions: Signal<ProductOption[]>;
250
+ /** Reactive signal containing selected product option filters */
251
+ selectedProductOptions: Signal<Record<string, string[]>>;
252
+ /** Function to set the minimum price filter */
253
+ setMinPrice: (minPrice: number) => void;
254
+ /** Function to set the maximum price filter */
255
+ setMaxPrice: (maxPrice: number) => void;
256
+ /** Function to toggle an inventory status filter */
257
+ toggleInventoryStatus: (status: InventoryStatusType) => void;
258
+ /** Function to toggle a product option choice filter */
259
+ toggleProductOption: (optionId: string, choiceId: string) => void;
260
+ /** Reactive signal indicating if any filters are currently applied */
261
+ isFiltered: Signal<boolean>;
262
+ /** Function to reset all filters to their default state */
263
+ reset: () => void;
264
+ };
265
+ __config: {};
266
+ isServiceDefinition?: boolean;
267
+ } & {
268
+ /** Reactive signal containing the minimum price filter value */
269
+ minPrice: Signal<number>;
270
+ /** Reactive signal containing the maximum price filter value */
271
+ maxPrice: Signal<number>;
272
+ /** Reactive signal containing available inventory status options */
273
+ availableInventoryStatuses: Signal<InventoryStatusType[]>;
274
+ /** Reactive signal containing selected inventory status filters */
275
+ selectedInventoryStatuses: Signal<InventoryStatusType[]>;
276
+ /** Reactive signal containing available product options for filtering */
277
+ availableProductOptions: Signal<ProductOption[]>;
278
+ /** Reactive signal containing selected product option filters */
279
+ selectedProductOptions: Signal<Record<string, string[]>>;
280
+ /** Function to set the minimum price filter */
281
+ setMinPrice: (minPrice: number) => void;
282
+ /** Function to set the maximum price filter */
283
+ setMaxPrice: (maxPrice: number) => void;
284
+ /** Function to toggle an inventory status filter */
285
+ toggleInventoryStatus: (status: InventoryStatusType) => void;
286
+ /** Function to toggle a product option choice filter */
287
+ toggleProductOption: (optionId: string, choiceId: string) => void;
288
+ /** Reactive signal indicating if any filters are currently applied */
289
+ isFiltered: Signal<boolean>;
290
+ /** Function to reset all filters to their default state */
291
+ reset: () => void;
292
+ }, ProductsListFiltersServiceConfig>;