@wix/headless-stores 0.0.109 → 0.0.111

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 (40) hide show
  1. package/cjs/dist/astro/actions/custom-checkout.d.ts +1 -3
  2. package/cjs/dist/astro/actions/custom-checkout.js +8 -4
  3. package/cjs/dist/astro/actions/index.js +17 -1
  4. package/cjs/dist/data-component-tags.js +5 -2
  5. package/cjs/dist/enums/index.js +18 -2
  6. package/cjs/dist/enums/social-platform-enums.js +7 -4
  7. package/cjs/dist/enums/sort-enums.js +6 -3
  8. package/cjs/dist/react/Category.js +64 -25
  9. package/cjs/dist/react/CategoryList.js +55 -14
  10. package/cjs/dist/react/Choice.js +32 -25
  11. package/cjs/dist/react/Option.js +68 -29
  12. package/cjs/dist/react/Product.js +194 -155
  13. package/cjs/dist/react/ProductList.js +84 -45
  14. package/cjs/dist/react/core/CategoryList.js +26 -16
  15. package/cjs/dist/react/core/Product.js +30 -20
  16. package/cjs/dist/react/core/ProductList.js +29 -21
  17. package/cjs/dist/react/core/ProductListFilters.js +30 -22
  18. package/cjs/dist/react/core/ProductListPagination.js +7 -4
  19. package/cjs/dist/react/core/ProductListSort.js +11 -6
  20. package/cjs/dist/react/core/ProductModifiers.js +25 -17
  21. package/cjs/dist/react/core/ProductVariantSelector.js +27 -19
  22. package/cjs/dist/react/core/SelectedVariant.js +28 -21
  23. package/cjs/dist/react/index.js +42 -6
  24. package/cjs/dist/react/types.js +5 -2
  25. package/cjs/dist/server-actions/custom-checkout-action.js +11 -8
  26. package/cjs/dist/server-actions/index.js +17 -1
  27. package/cjs/dist/services/buy-now-service.js +20 -15
  28. package/cjs/dist/services/categories-list-service.js +12 -8
  29. package/cjs/dist/services/index.js +25 -5
  30. package/cjs/dist/services/pay-now-service.js +16 -11
  31. package/cjs/dist/services/product-modifiers-service.js +16 -12
  32. package/cjs/dist/services/product-service.js +16 -12
  33. package/cjs/dist/services/products-list-search-service.d.ts +0 -1
  34. package/cjs/dist/services/products-list-search-service.js +1 -1
  35. package/cjs/dist/services/products-list-service.js +66 -59
  36. package/cjs/dist/services/selected-variant-service.js +21 -18
  37. package/cjs/dist/utils/index.js +9 -6
  38. package/cjs/dist/utils/url-params.js +5 -1
  39. package/dist/astro/actions/custom-checkout.d.ts +1 -3
  40. package/package.json +6 -6
@@ -1,14 +1,53 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Sort as SortPrimitive, GenericList, } from '@wix/headless-components/react';
3
- import { useService } from '@wix/services-manager-react';
4
- import React from 'react';
5
- import { ProductsListServiceDefinition } from '../services/products-list-service.js';
6
- import * as CoreProductList from './core/ProductList.js';
7
- import { ProductListSort as ProductListSortPrimitive } from './core/ProductListSort.js';
8
- import * as CoreProductListFilters from './core/ProductListFilters.js';
9
- import * as Product from './Product.js';
10
- import { AsChildSlot } from '@wix/headless-utils/react';
11
- import { DataComponentTags } from '../data-component-tags.js';
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Error = exports.FilterResetTrigger = exports.Filter = exports.Sort = exports.TotalsDisplayed = exports.LoadMoreTrigger = exports.ProductRepeater = exports.Products = exports.Raw = exports.Root = void 0;
40
+ const jsx_runtime_1 = require("react/jsx-runtime");
41
+ const react_1 = require("@wix/headless-components/react");
42
+ const services_manager_react_1 = require("@wix/services-manager-react");
43
+ const react_2 = __importDefault(require("react"));
44
+ const products_list_service_js_1 = require("../services/products-list-service.js");
45
+ const CoreProductList = __importStar(require("./core/ProductList.js"));
46
+ const ProductListSort_js_1 = require("./core/ProductListSort.js");
47
+ const CoreProductListFilters = __importStar(require("./core/ProductListFilters.js"));
48
+ const Product = __importStar(require("./Product.js"));
49
+ const react_3 = require("@wix/headless-utils/react");
50
+ const data_component_tags_js_1 = require("../data-component-tags.js");
12
51
  var TestIds;
13
52
  (function (TestIds) {
14
53
  TestIds["productListRoot"] = "product-list-root";
@@ -44,7 +83,7 @@ var TestIds;
44
83
  * }
45
84
  * ```
46
85
  */
47
- export const Root = React.forwardRef((props, ref) => {
86
+ exports.Root = react_2.default.forwardRef((props, ref) => {
48
87
  const { children, products, productsListConfig, className, variant } = props;
49
88
  const serviceConfig = productsListConfig || {
50
89
  products: products || [],
@@ -59,20 +98,20 @@ export const Root = React.forwardRef((props, ref) => {
59
98
  }, // Empty aggregation data
60
99
  customizations: [],
61
100
  };
62
- return (_jsx(CoreProductList.Root, { productsListConfig: serviceConfig, children: _jsx(RootContent, { children: children, className: className, ref: ref, variant: variant }) }));
101
+ return ((0, jsx_runtime_1.jsx)(CoreProductList.Root, { productsListConfig: serviceConfig, children: (0, jsx_runtime_1.jsx)(RootContent, { children: children, className: className, ref: ref, variant: variant }) }));
63
102
  });
64
- Root.displayName = 'ProductList.Root';
103
+ exports.Root.displayName = 'ProductList.Root';
65
104
  /**
66
105
  * Internal component to handle the Root content with service access
67
106
  */
68
- const RootContent = React.forwardRef((props, ref) => {
107
+ const RootContent = react_2.default.forwardRef((props, ref) => {
69
108
  const { children, className, variant } = props;
70
- const productsListService = useService(ProductsListServiceDefinition);
109
+ const productsListService = (0, services_manager_react_1.useService)(products_list_service_js_1.ProductsListServiceDefinition);
71
110
  const items = productsListService.products.get().map((product) => ({
72
111
  ...product,
73
112
  id: product._id,
74
113
  }));
75
- return (_jsx(GenericList.Root, { items: items, loadMore: () => productsListService.loadMore(10), hasMore: productsListService.hasMoreProducts.get(), isLoading: productsListService.isLoading.get(), className: className, ref: ref, "data-component-tag": DataComponentTags.productListRoot, "data-testid": TestIds.productListRoot, variant: variant, children: children }));
114
+ return ((0, jsx_runtime_1.jsx)(react_1.GenericList.Root, { items: items, loadMore: () => productsListService.loadMore(10), hasMore: productsListService.hasMoreProducts.get(), isLoading: productsListService.isLoading.get(), className: className, ref: ref, "data-component-tag": data_component_tags_js_1.DataComponentTags.productListRoot, "data-testid": TestIds.productListRoot, variant: variant, children: children }));
76
115
  });
77
116
  /**
78
117
  * Raw component that provides direct access to product list data.
@@ -91,9 +130,9 @@ const RootContent = React.forwardRef((props, ref) => {
91
130
  * </ProductList.Raw>
92
131
  * ```
93
132
  */
94
- export const Raw = React.forwardRef((props, _ref) => {
133
+ exports.Raw = react_2.default.forwardRef((props, _ref) => {
95
134
  const { children } = props;
96
- const productsListService = useService(ProductsListServiceDefinition);
135
+ const productsListService = (0, services_manager_react_1.useService)(products_list_service_js_1.ProductsListServiceDefinition);
97
136
  const products = productsListService.products.get();
98
137
  const pagingMetadata = productsListService.pagingMetadata.get();
99
138
  const displayedProducts = products.length;
@@ -118,9 +157,9 @@ export const Raw = React.forwardRef((props, _ref) => {
118
157
  * </ProductList.Products>
119
158
  * ```
120
159
  */
121
- export const Products = React.forwardRef((props, ref) => {
160
+ exports.Products = react_2.default.forwardRef((props, ref) => {
122
161
  const { children, ...otherProps } = props;
123
- return (_jsx(GenericList.Items, { ref: ref, "data-testid": TestIds.productListProducts, ...otherProps, children: children }));
162
+ return ((0, jsx_runtime_1.jsx)(react_1.GenericList.Items, { ref: ref, "data-testid": TestIds.productListProducts, ...otherProps, children: children }));
124
163
  });
125
164
  /**
126
165
  * Repeater component that renders Product.Root for each product.
@@ -153,9 +192,9 @@ export const Products = React.forwardRef((props, ref) => {
153
192
  * </ProductList.ProductRepeater>
154
193
  * ```
155
194
  */
156
- export const ProductRepeater = React.forwardRef((props, ref) => {
195
+ exports.ProductRepeater = react_2.default.forwardRef((props, ref) => {
157
196
  const { children, asChild } = props;
158
- return (_jsx(GenericList.Repeater, { ref: ref, asChild: asChild, itemWrapper: ({ item: product, children }) => (_jsx(Product.Root, { product: product, "data-testid": TestIds.productListItem, "data-product-id": product._id, "data-product-available": true, "data-item-id": product._id, children: children }, product._id)), children: children }));
197
+ return ((0, jsx_runtime_1.jsx)(react_1.GenericList.Repeater, { ref: ref, asChild: asChild, itemWrapper: ({ item: product, children }) => ((0, jsx_runtime_1.jsx)(Product.Root, { product: product, "data-testid": TestIds.productListItem, "data-product-id": product._id, "data-product-available": true, "data-item-id": product._id, children: children }, product._id)), children: children }));
159
198
  });
160
199
  /**
161
200
  * Displays a button to load more products. Not rendered if infiniteScroll is false or no products are left to load.
@@ -169,9 +208,9 @@ export const ProductRepeater = React.forwardRef((props, ref) => {
169
208
  * </ProductList.LoadMoreTrigger>
170
209
  * ```
171
210
  */
172
- export const LoadMoreTrigger = React.forwardRef((props, ref) => {
173
- const { children = _jsx("button", {}), ...otherProps } = props;
174
- return (_jsx(GenericList.Actions.LoadMore, { ref: ref, "data-testid": TestIds.productListLoadMore, ...otherProps, children: children }));
211
+ exports.LoadMoreTrigger = react_2.default.forwardRef((props, ref) => {
212
+ const { children = (0, jsx_runtime_1.jsx)("button", {}), ...otherProps } = props;
213
+ return ((0, jsx_runtime_1.jsx)(react_1.GenericList.Actions.LoadMore, { ref: ref, "data-testid": TestIds.productListLoadMore, ...otherProps, children: children }));
175
214
  });
176
215
  /**
177
216
  * Displays the number of products currently displayed.
@@ -190,9 +229,9 @@ export const LoadMoreTrigger = React.forwardRef((props, ref) => {
190
229
  * </ProductList.TotalsDisplayed>
191
230
  * ```
192
231
  */
193
- export const TotalsDisplayed = React.forwardRef((props, ref) => {
194
- const { children = _jsx("span", {}), ...otherProps } = props;
195
- return (_jsx(GenericList.Totals, { ref: ref, "data-testid": TestIds.productListTotalsDisplayed, ...otherProps, children: children }));
232
+ exports.TotalsDisplayed = react_2.default.forwardRef((props, ref) => {
233
+ const { children = (0, jsx_runtime_1.jsx)("span", {}), ...otherProps } = props;
234
+ return ((0, jsx_runtime_1.jsx)(react_1.GenericList.Totals, { ref: ref, "data-testid": TestIds.productListTotalsDisplayed, ...otherProps, children: children }));
196
235
  });
197
236
  /**
198
237
  * Sort component for product lists that provides sorting functionality.
@@ -237,12 +276,12 @@ export const TotalsDisplayed = React.forwardRef((props, ref) => {
237
276
  * @see {@link ProductListSortPrimitive} for the underlying sort logic
238
277
  * @see {@link SortPrimitive.Root} for the primitive sort component
239
278
  */
240
- export const Sort = React.forwardRef(({ children, className, as, asChild }, ref) => {
241
- return (_jsx(ProductListSortPrimitive, { children: ({ currentSort, sortOptions, setSort }) => {
279
+ exports.Sort = react_2.default.forwardRef(({ children, className, as, asChild }, ref) => {
280
+ return ((0, jsx_runtime_1.jsx)(ProductListSort_js_1.ProductListSort, { children: ({ currentSort, sortOptions, setSort }) => {
242
281
  if (asChild && children) {
243
282
  return children({ currentSort, sortOptions, setSort });
244
283
  }
245
- return (_jsx(SortPrimitive.Root, { ref: ref, value: currentSort, onChange: (value) => {
284
+ return ((0, jsx_runtime_1.jsx)(react_1.Sort.Root, { ref: ref, value: currentSort, onChange: (value) => {
246
285
  setSort(value);
247
286
  }, sortOptions: sortOptions, as: as, className: className, "data-testid": TestIds.productListSort }));
248
287
  } }));
@@ -277,12 +316,12 @@ export const Sort = React.forwardRef(({ children, className, as, asChild }, ref)
277
316
  * </ProductList.Filter.Root>
278
317
  * ```
279
318
  */
280
- const FilterRoot = React.forwardRef((props, ref) => {
319
+ const FilterRoot = react_2.default.forwardRef((props, ref) => {
281
320
  const { asChild, children, className, ...otherProps } = props;
282
- return (_jsx(CoreProductListFilters.FilterRoot, { asChild: asChild, className: className, children: _jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productListFilter, customElement: children, ...otherProps, children: _jsx("div", { children: children }) }) }));
321
+ return ((0, jsx_runtime_1.jsx)(CoreProductListFilters.FilterRoot, { asChild: asChild, className: className, children: (0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productListFilter, customElement: children, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { children: children }) }) }));
283
322
  });
284
323
  FilterRoot.displayName = 'ProductList.Filter';
285
- export const Filter = {
324
+ exports.Filter = {
286
325
  Root: FilterRoot,
287
326
  };
288
327
  /**
@@ -315,20 +354,20 @@ export const Filter = {
315
354
  * </ProductList.FilterResetTrigger>
316
355
  * ```
317
356
  */
318
- export const FilterResetTrigger = React.forwardRef((props, ref) => {
357
+ exports.FilterResetTrigger = react_2.default.forwardRef((props, ref) => {
319
358
  const { asChild, children, className, ...otherProps } = props;
320
359
  const label = props.label || 'Reset All Filters';
321
- return (_jsx(CoreProductListFilters.ResetTrigger, { children: ({ resetFilters, isFiltered }) => {
360
+ return ((0, jsx_runtime_1.jsx)(CoreProductListFilters.ResetTrigger, { children: ({ resetFilters, isFiltered }) => {
322
361
  if (!isFiltered) {
323
362
  return null;
324
363
  }
325
- return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, onClick: resetFilters, disabled: !isFiltered, "data-testid": TestIds.productListFilterResetTrigger, "data-filtered": isFiltered ? 'true' : 'false', customElement: children, customElementProps: {
364
+ return ((0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, className: className, onClick: resetFilters, disabled: !isFiltered, "data-testid": TestIds.productListFilterResetTrigger, "data-filtered": isFiltered ? 'true' : 'false', customElement: children, customElementProps: {
326
365
  resetFilters,
327
366
  isFiltered,
328
- }, content: label, ...otherProps, children: _jsx("button", { disabled: !isFiltered, children: label }) }));
367
+ }, content: label, ...otherProps, children: (0, jsx_runtime_1.jsx)("button", { disabled: !isFiltered, children: label }) }));
329
368
  } }));
330
369
  });
331
- FilterResetTrigger.displayName = 'ProductList.FilterResetTrigger';
370
+ exports.FilterResetTrigger.displayName = 'ProductList.FilterResetTrigger';
332
371
  /**
333
372
  * Error component that displays product list errors.
334
373
  * Provides error data to custom render functions.
@@ -354,15 +393,15 @@ FilterResetTrigger.displayName = 'ProductList.FilterResetTrigger';
354
393
  * </ProductList.Error>
355
394
  * ```
356
395
  */
357
- export const Error = React.forwardRef((props, ref) => {
396
+ exports.Error = react_2.default.forwardRef((props, ref) => {
358
397
  const { asChild, children, className, ...otherProps } = props;
359
- return (_jsx(CoreProductList.Error, { children: ({ error }) => {
398
+ return ((0, jsx_runtime_1.jsx)(CoreProductList.Error, { children: ({ error }) => {
360
399
  if (!error) {
361
400
  return null;
362
401
  }
363
- return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productListError, "data-error": error, customElement: children, customElementProps: {
402
+ return ((0, jsx_runtime_1.jsx)(react_3.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productListError, "data-error": error, customElement: children, customElementProps: {
364
403
  error,
365
- }, content: error, ...otherProps, children: _jsx("div", { className: "text-status-error text-sm sm:text-base", children: error }) }));
404
+ }, content: error, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { className: "text-status-error text-sm sm:text-base", children: error }) }));
366
405
  } }));
367
406
  });
368
- Error.displayName = 'ProductList.Error';
407
+ exports.Error.displayName = 'ProductList.Error';
@@ -1,8 +1,18 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import React from 'react';
3
- import { useService, WixServices } from '@wix/services-manager-react';
4
- import { createServicesMap } from '@wix/services-manager';
5
- import { CategoriesListService, CategoriesListServiceDefinition, } from '../../services/categories-list-service.js';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Root = Root;
7
+ exports.EmptyState = EmptyState;
8
+ exports.Loading = Loading;
9
+ exports.Error = Error;
10
+ exports.ItemContent = ItemContent;
11
+ const jsx_runtime_1 = require("react/jsx-runtime");
12
+ const react_1 = __importDefault(require("react"));
13
+ const services_manager_react_1 = require("@wix/services-manager-react");
14
+ const services_manager_1 = require("@wix/services-manager");
15
+ const categories_list_service_js_1 = require("../../services/categories-list-service.js");
6
16
  /**
7
17
  * Root component that provides the CategoryList service context to its children.
8
18
  * This component sets up the necessary services for managing categories list state.
@@ -32,9 +42,9 @@ import { CategoriesListService, CategoriesListServiceDefinition, } from '../../s
32
42
  * }
33
43
  * ```
34
44
  */
35
- export function Root(props) {
45
+ function Root(props) {
36
46
  const { categoriesListConfig, children } = props;
37
- return (_jsx(WixServices, { servicesMap: createServicesMap().addService(CategoriesListServiceDefinition, CategoriesListService, categoriesListConfig), children: children }));
47
+ return ((0, jsx_runtime_1.jsx)(services_manager_react_1.WixServices, { servicesMap: (0, services_manager_1.createServicesMap)().addService(categories_list_service_js_1.CategoriesListServiceDefinition, categories_list_service_js_1.CategoriesListService, categoriesListConfig), children: children }));
38
48
  }
39
49
  Root.displayName = 'CategoryList.Root';
40
50
  /**
@@ -60,8 +70,8 @@ Root.displayName = 'CategoryList.Root';
60
70
  * }
61
71
  * ```
62
72
  */
63
- export function EmptyState(props) {
64
- const { isLoading, error, categories } = useService(CategoriesListServiceDefinition);
73
+ function EmptyState(props) {
74
+ const { isLoading, error, categories } = (0, services_manager_react_1.useService)(categories_list_service_js_1.CategoriesListServiceDefinition);
65
75
  const isLoadingValue = isLoading.get();
66
76
  const errorValue = error.get();
67
77
  const categoriesValue = categories.get();
@@ -95,8 +105,8 @@ export function EmptyState(props) {
95
105
  * }
96
106
  * ```
97
107
  */
98
- export function Loading(props) {
99
- const { isLoading } = useService(CategoriesListServiceDefinition);
108
+ function Loading(props) {
109
+ const { isLoading } = (0, services_manager_react_1.useService)(categories_list_service_js_1.CategoriesListServiceDefinition);
100
110
  const isLoadingValue = isLoading.get();
101
111
  if (isLoadingValue) {
102
112
  return typeof props.children === 'function'
@@ -131,8 +141,8 @@ export function Loading(props) {
131
141
  * }
132
142
  * ```
133
143
  */
134
- export function Error(props) {
135
- const { error } = useService(CategoriesListServiceDefinition);
144
+ function Error(props) {
145
+ const { error } = (0, services_manager_react_1.useService)(categories_list_service_js_1.CategoriesListServiceDefinition);
136
146
  const errorValue = error.get();
137
147
  if (errorValue) {
138
148
  return typeof props.children === 'function'
@@ -166,13 +176,13 @@ export function Error(props) {
166
176
  * }
167
177
  * ```
168
178
  */
169
- export function ItemContent(props) {
170
- const { categories, isLoading, error } = useService(CategoriesListServiceDefinition);
179
+ function ItemContent(props) {
180
+ const { categories, isLoading, error } = (0, services_manager_react_1.useService)(categories_list_service_js_1.CategoriesListServiceDefinition);
171
181
  const categoriesValue = categories.get();
172
182
  if (isLoading.get() || error.get() || categoriesValue.length === 0) {
173
183
  return null;
174
184
  }
175
- return categoriesValue.map((category) => (_jsx(React.Fragment, { children: typeof props.children === 'function'
185
+ return categoriesValue.map((category) => ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: typeof props.children === 'function'
176
186
  ? props.children({
177
187
  category,
178
188
  })
@@ -1,7 +1,17 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useService, WixServices } from '@wix/services-manager-react';
3
- import { ProductServiceDefinition, ProductService, } from '../../services/product-service.js';
4
- import { createServicesMap } from '@wix/services-manager';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Root = Root;
4
+ exports.Name = Name;
5
+ exports.Description = Description;
6
+ exports.Media = Media;
7
+ exports.Content = Content;
8
+ exports.Loading = Loading;
9
+ exports.Slug = Slug;
10
+ exports.Ribbon = Ribbon;
11
+ const jsx_runtime_1 = require("react/jsx-runtime");
12
+ const services_manager_react_1 = require("@wix/services-manager-react");
13
+ const product_service_js_1 = require("../../services/product-service.js");
14
+ const services_manager_1 = require("@wix/services-manager");
5
15
  /**
6
16
  * Root component that provides the Product service context to its children.
7
17
  * This component sets up the necessary services for rendering and managing a single product's data.
@@ -32,8 +42,8 @@ import { createServicesMap } from '@wix/services-manager';
32
42
  * }
33
43
  * ```
34
44
  */
35
- export function Root(props) {
36
- return (_jsx(WixServices, { servicesMap: createServicesMap().addService(ProductServiceDefinition, ProductService, props.productServiceConfig), children: props.children }));
45
+ function Root(props) {
46
+ return ((0, jsx_runtime_1.jsx)(services_manager_react_1.WixServices, { servicesMap: (0, services_manager_1.createServicesMap)().addService(product_service_js_1.ProductServiceDefinition, product_service_js_1.ProductService, props.productServiceConfig), children: props.children }));
37
47
  }
38
48
  /**
39
49
  * Headless component for product name display
@@ -54,8 +64,8 @@ export function Root(props) {
54
64
  * }
55
65
  * ```
56
66
  */
57
- export function Name(props) {
58
- const service = useService(ProductServiceDefinition);
67
+ function Name(props) {
68
+ const service = (0, services_manager_react_1.useService)(product_service_js_1.ProductServiceDefinition);
59
69
  const product = service.product.get();
60
70
  const name = product.name;
61
71
  return props.children({
@@ -92,8 +102,8 @@ export function Name(props) {
92
102
  * }
93
103
  * ```
94
104
  */
95
- export function Description(props) {
96
- const service = useService(ProductServiceDefinition);
105
+ function Description(props) {
106
+ const service = (0, services_manager_react_1.useService)(product_service_js_1.ProductServiceDefinition);
97
107
  const product = service.product.get();
98
108
  const descriptionRichContent = product.description;
99
109
  const plainDescription = product.plainDescription;
@@ -102,8 +112,8 @@ export function Description(props) {
102
112
  plainDescription: plainDescription,
103
113
  });
104
114
  }
105
- export function Media(props) {
106
- const service = useService(ProductServiceDefinition);
115
+ function Media(props) {
116
+ const service = (0, services_manager_react_1.useService)(product_service_js_1.ProductServiceDefinition);
107
117
  const product = service.product.get();
108
118
  const mainMedia = product.media?.main;
109
119
  const mediaItems = product.media?.itemsInfo?.items ?? [];
@@ -112,15 +122,15 @@ export function Media(props) {
112
122
  mainMedia,
113
123
  });
114
124
  }
115
- export function Content(props) {
116
- const service = useService(ProductServiceDefinition);
125
+ function Content(props) {
126
+ const service = (0, services_manager_react_1.useService)(product_service_js_1.ProductServiceDefinition);
117
127
  const product = service.product.get();
118
128
  return props.children({
119
129
  product,
120
130
  });
121
131
  }
122
- export function Loading(props) {
123
- const service = useService(ProductServiceDefinition);
132
+ function Loading(props) {
133
+ const service = (0, services_manager_react_1.useService)(product_service_js_1.ProductServiceDefinition);
124
134
  const isLoading = service.isLoading.get();
125
135
  return props.children({
126
136
  isLoading,
@@ -147,8 +157,8 @@ export function Loading(props) {
147
157
  * }
148
158
  * ```
149
159
  */
150
- export function Slug(props) {
151
- const service = useService(ProductServiceDefinition);
160
+ function Slug(props) {
161
+ const service = (0, services_manager_react_1.useService)(product_service_js_1.ProductServiceDefinition);
152
162
  const product = service.product.get();
153
163
  const slug = product.slug;
154
164
  return props.children({
@@ -178,8 +188,8 @@ export function Slug(props) {
178
188
  * }
179
189
  * ```
180
190
  */
181
- export function Ribbon(props) {
182
- const service = useService(ProductServiceDefinition);
191
+ function Ribbon(props) {
192
+ const service = (0, services_manager_react_1.useService)(product_service_js_1.ProductServiceDefinition);
183
193
  const product = service.product.get();
184
194
  const ribbon = product.ribbon?.name || null;
185
195
  const hasRibbon = !!ribbon;
@@ -1,9 +1,17 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useService, WixServices } from '@wix/services-manager-react';
3
- import { createServicesMap } from '@wix/services-manager';
4
- import { ProductListService, ProductsListServiceDefinition, } from '../../services/products-list-service.js';
5
- import { ProductService, ProductServiceDefinition, } from '../../services/product-service.js';
6
- import { CategoriesListService, CategoriesListServiceDefinition, } from '../../services/categories-list-service.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Root = Root;
4
+ exports.EmptyState = EmptyState;
5
+ exports.Loading = Loading;
6
+ exports.Error = Error;
7
+ exports.ItemContent = ItemContent;
8
+ exports.Items = Items;
9
+ const jsx_runtime_1 = require("react/jsx-runtime");
10
+ const services_manager_react_1 = require("@wix/services-manager-react");
11
+ const services_manager_1 = require("@wix/services-manager");
12
+ const products_list_service_js_1 = require("../../services/products-list-service.js");
13
+ const product_service_js_1 = require("../../services/product-service.js");
14
+ const categories_list_service_js_1 = require("../../services/categories-list-service.js");
7
15
  /**
8
16
  * Root component that provides both ProductList and ProductListSearch service contexts to its children.
9
17
  * This component sets up the necessary services for managing products list state, including search,
@@ -62,10 +70,10 @@ import { CategoriesListService, CategoriesListServiceDefinition, } from '../../s
62
70
  * }
63
71
  * ```
64
72
  */
65
- export function Root(props) {
66
- return (_jsx(WixServices, { servicesMap: createServicesMap()
67
- .addService(CategoriesListServiceDefinition, CategoriesListService, props.categoriesListConfig)
68
- .addService(ProductsListServiceDefinition, ProductListService, props.productsListConfig), children: props.children }));
73
+ function Root(props) {
74
+ return ((0, jsx_runtime_1.jsx)(services_manager_react_1.WixServices, { servicesMap: (0, services_manager_1.createServicesMap)()
75
+ .addService(categories_list_service_js_1.CategoriesListServiceDefinition, categories_list_service_js_1.CategoriesListService, props.categoriesListConfig)
76
+ .addService(products_list_service_js_1.ProductsListServiceDefinition, products_list_service_js_1.ProductListService, props.productsListConfig), children: props.children }));
69
77
  }
70
78
  /**
71
79
  * Component that renders content when the products list is empty.
@@ -91,8 +99,8 @@ export function Root(props) {
91
99
  * }
92
100
  * ```
93
101
  */
94
- export function EmptyState(props) {
95
- const { isLoading, error, products } = useService(ProductsListServiceDefinition);
102
+ function EmptyState(props) {
103
+ const { isLoading, error, products } = (0, services_manager_react_1.useService)(products_list_service_js_1.ProductsListServiceDefinition);
96
104
  const isLoadingValue = isLoading.get();
97
105
  const errorValue = error.get();
98
106
  const productsValue = products.get();
@@ -126,8 +134,8 @@ export function EmptyState(props) {
126
134
  * }
127
135
  * ```
128
136
  */
129
- export function Loading(props) {
130
- const { isLoading } = useService(ProductsListServiceDefinition);
137
+ function Loading(props) {
138
+ const { isLoading } = (0, services_manager_react_1.useService)(products_list_service_js_1.ProductsListServiceDefinition);
131
139
  const isLoadingValue = isLoading.get();
132
140
  if (isLoadingValue) {
133
141
  return typeof props.children === 'function'
@@ -162,8 +170,8 @@ export function Loading(props) {
162
170
  * }
163
171
  * ```
164
172
  */
165
- export function Error(props) {
166
- const { error } = useService(ProductsListServiceDefinition);
173
+ function Error(props) {
174
+ const { error } = (0, services_manager_react_1.useService)(products_list_service_js_1.ProductsListServiceDefinition);
167
175
  const errorValue = error.get();
168
176
  if (errorValue) {
169
177
  return typeof props.children === 'function'
@@ -198,18 +206,18 @@ export function Error(props) {
198
206
  * }
199
207
  * ```
200
208
  */
201
- export function ItemContent(props) {
202
- const { products, isLoading, error } = useService(ProductsListServiceDefinition);
209
+ function ItemContent(props) {
210
+ const { products, isLoading, error } = (0, services_manager_react_1.useService)(products_list_service_js_1.ProductsListServiceDefinition);
203
211
  const productsValue = products.get();
204
212
  if (isLoading.get() || error.get() || productsValue.length === 0) {
205
213
  return null;
206
214
  }
207
- return productsValue.map((product) => (_jsx(WixServices, { servicesMap: createServicesMap().addService(ProductServiceDefinition, ProductService, { product }), children: typeof props.children === 'function'
215
+ return productsValue.map((product) => ((0, jsx_runtime_1.jsx)(services_manager_react_1.WixServices, { servicesMap: (0, services_manager_1.createServicesMap)().addService(product_service_js_1.ProductServiceDefinition, product_service_js_1.ProductService, { product }), children: typeof props.children === 'function'
208
216
  ? props.children({ product })
209
217
  : props.children }, product._id)));
210
218
  }
211
- export function Items(props) {
212
- const { products } = useService(ProductsListServiceDefinition);
219
+ function Items(props) {
220
+ const { products } = (0, services_manager_react_1.useService)(products_list_service_js_1.ProductsListServiceDefinition);
213
221
  const productsValue = products.get();
214
222
  return typeof props.children === 'function'
215
223
  ? props.children({ products: productsValue })
@@ -1,18 +1,26 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useService } from '@wix/services-manager-react';
3
- import { ProductsListServiceDefinition, InventoryStatusType, CategoriesListServiceDefinition, } from '../../services/index.js';
4
- import { useMemo } from 'react';
5
- import { Filter as FilterPrimitive, } from '@wix/headless-components/react';
6
- import { Slot } from '@radix-ui/react-slot';
7
- import React from 'react';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FilterRoot = void 0;
7
+ exports.ResetTrigger = ResetTrigger;
8
+ exports.CategoryFilter = CategoryFilter;
9
+ const jsx_runtime_1 = require("react/jsx-runtime");
10
+ const services_manager_react_1 = require("@wix/services-manager-react");
11
+ const index_js_1 = require("../../services/index.js");
12
+ const react_1 = require("react");
13
+ const react_2 = require("@wix/headless-components/react");
14
+ const react_slot_1 = require("@radix-ui/react-slot");
15
+ const react_3 = __importDefault(require("react"));
8
16
  // Conversion utilities for platform compatibility
9
17
  function getInventoryStatusLabel(status) {
10
18
  switch (status) {
11
- case InventoryStatusType.IN_STOCK:
19
+ case index_js_1.InventoryStatusType.IN_STOCK:
12
20
  return 'In Stock';
13
- case InventoryStatusType.OUT_OF_STOCK:
21
+ case index_js_1.InventoryStatusType.OUT_OF_STOCK:
14
22
  return 'Out of Stock';
15
- case InventoryStatusType.PARTIALLY_OUT_OF_STOCK:
23
+ case index_js_1.InventoryStatusType.PARTIALLY_OUT_OF_STOCK:
16
24
  return 'Limited Stock';
17
25
  default:
18
26
  return String(status);
@@ -112,17 +120,17 @@ function buildSearchFilterData(availableOptions, availableInventoryStatuses, ava
112
120
  * }
113
121
  * ```
114
122
  */
115
- export function ResetTrigger(props) {
116
- const service = useService(ProductsListServiceDefinition);
123
+ function ResetTrigger(props) {
124
+ const service = (0, services_manager_react_1.useService)(index_js_1.ProductsListServiceDefinition);
117
125
  const resetFilters = service.resetFilter;
118
126
  const isFiltered = service.isFiltered().get();
119
127
  return typeof props.children === 'function'
120
128
  ? props.children({ resetFilters, isFiltered })
121
129
  : props.children;
122
130
  }
123
- export function CategoryFilter(props) {
124
- const categoriesService = useService(CategoriesListServiceDefinition);
125
- const productListService = useService(ProductsListServiceDefinition);
131
+ function CategoryFilter(props) {
132
+ const categoriesService = (0, services_manager_react_1.useService)(index_js_1.CategoriesListServiceDefinition);
133
+ const productListService = (0, services_manager_react_1.useService)(index_js_1.ProductsListServiceDefinition);
126
134
  const categories = categoriesService.categories.get();
127
135
  const setSelectedCategory = (category) => {
128
136
  const currentFilter = productListService.searchOptions.get().filter || {};
@@ -150,7 +158,7 @@ export function CategoryFilter(props) {
150
158
  * Consolidates data from both search and list services.
151
159
  */
152
160
  function AllFilters(props) {
153
- const listService = useService(ProductsListServiceDefinition);
161
+ const listService = (0, services_manager_react_1.useService)(index_js_1.ProductsListServiceDefinition);
154
162
  // Get current filter state
155
163
  const currentSearchOptions = listService.searchOptions.get();
156
164
  const currentFilter = currentSearchOptions.filter;
@@ -164,7 +172,7 @@ function AllFilters(props) {
164
172
  const resetFilters = listService.resetFilter;
165
173
  const isFiltered = listService.isFiltered().get();
166
174
  // Build filter options and handlers
167
- const searchFilterData = useMemo(() => {
175
+ const searchFilterData = (0, react_1.useMemo)(() => {
168
176
  const { filterOptions } = buildSearchFilterData(availableOptions, availableInventoryStatuses, availableMinPrice, availableMaxPrice, currency);
169
177
  const updateFilter = (newFilter) => {
170
178
  listService.setFilter(newFilter);
@@ -246,10 +254,10 @@ function AllFilters(props) {
246
254
  * @see {@link FilterPrimitive.Root} for the primitive filter component
247
255
  * @see {@link ResetTrigger} for filter reset functionality
248
256
  */
249
- export const FilterRoot = React.forwardRef(({ children, className, asChild }, ref) => {
250
- const Comp = asChild ? Slot : 'div';
251
- return (_jsx(AllFilters, { children: ({ searchFilter }) => {
252
- return (_jsx(FilterPrimitive.Root, { value: searchFilter.filterValue, onChange: searchFilter.updateFilter, filterOptions: searchFilter.filterOptions, children: _jsx(Comp, { className: className, ref: ref, children: children }) }));
257
+ exports.FilterRoot = react_3.default.forwardRef(({ children, className, asChild }, ref) => {
258
+ const Comp = asChild ? react_slot_1.Slot : 'div';
259
+ return ((0, jsx_runtime_1.jsx)(AllFilters, { children: ({ searchFilter }) => {
260
+ return ((0, jsx_runtime_1.jsx)(react_2.Filter.Root, { value: searchFilter.filterValue, onChange: searchFilter.updateFilter, filterOptions: searchFilter.filterOptions, children: (0, jsx_runtime_1.jsx)(Comp, { className: className, ref: ref, children: children }) }));
253
261
  } }));
254
262
  });
255
- FilterRoot.displayName = 'ProductList.Filter';
263
+ exports.FilterRoot.displayName = 'ProductList.Filter';