@wix/headless-stores 0.0.12 → 0.0.14

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/astro/actions/custom-checkout.d.ts +4 -2
  2. package/cjs/dist/astro/actions/custom-checkout.js +4 -8
  3. package/cjs/dist/astro/actions/index.d.ts +1 -1
  4. package/cjs/dist/astro/actions/index.js +1 -17
  5. package/cjs/dist/enums/index.d.ts +2 -2
  6. package/cjs/dist/enums/index.js +2 -18
  7. package/cjs/dist/enums/social-platform-enums.js +4 -7
  8. package/cjs/dist/enums/sort-enums.js +3 -6
  9. package/cjs/dist/react/BuyNow.js +6 -11
  10. package/cjs/dist/react/Category.d.ts +2 -2
  11. package/cjs/dist/react/Category.js +6 -10
  12. package/cjs/dist/react/Collection.d.ts +1 -1
  13. package/cjs/dist/react/Collection.js +31 -39
  14. package/cjs/dist/react/FilteredCollection.d.ts +6 -20
  15. package/cjs/dist/react/FilteredCollection.js +29 -57
  16. package/cjs/dist/react/PayNow.js +4 -9
  17. package/cjs/dist/react/Product.d.ts +3 -3
  18. package/cjs/dist/react/Product.js +6 -11
  19. package/cjs/dist/react/ProductActions.js +12 -17
  20. package/cjs/dist/react/ProductModifiers.d.ts +3 -1
  21. package/cjs/dist/react/ProductModifiers.js +23 -29
  22. package/cjs/dist/react/ProductVariantSelector.d.ts +1 -1
  23. package/cjs/dist/react/ProductVariantSelector.js +18 -28
  24. package/cjs/dist/react/RelatedProducts.d.ts +2 -2
  25. package/cjs/dist/react/RelatedProducts.js +35 -33
  26. package/cjs/dist/react/SelectedVariant.js +8 -14
  27. package/cjs/dist/react/SocialSharing.d.ts +2 -3
  28. package/cjs/dist/react/SocialSharing.js +35 -33
  29. package/cjs/dist/react/Sort.d.ts +4 -3
  30. package/cjs/dist/react/Sort.js +6 -10
  31. package/cjs/dist/react/index.d.ts +13 -13
  32. package/cjs/dist/react/index.js +13 -52
  33. package/cjs/dist/server-actions/custom-checkout-action.js +8 -11
  34. package/cjs/dist/server-actions/index.d.ts +1 -1
  35. package/cjs/dist/server-actions/index.js +1 -17
  36. package/cjs/dist/services/buy-now-service.d.ts +44 -3
  37. package/cjs/dist/services/buy-now-service.js +20 -22
  38. package/cjs/dist/services/catalog-options-service.d.ts +3 -3
  39. package/cjs/dist/services/catalog-options-service.js +45 -46
  40. package/cjs/dist/services/catalog-price-range-service.d.ts +3 -3
  41. package/cjs/dist/services/catalog-price-range-service.js +21 -25
  42. package/cjs/dist/services/category-service.d.ts +7 -7
  43. package/cjs/dist/services/category-service.js +20 -22
  44. package/cjs/dist/services/collection-service.d.ts +8 -8
  45. package/cjs/dist/services/collection-service.js +102 -133
  46. package/cjs/dist/services/filter-service.d.ts +4 -4
  47. package/cjs/dist/services/filter-service.js +47 -61
  48. package/cjs/dist/services/index.d.ts +13 -2
  49. package/cjs/dist/services/index.js +13 -9
  50. package/cjs/dist/services/pay-now-service.d.ts +4 -3
  51. package/cjs/dist/services/pay-now-service.js +11 -16
  52. package/cjs/dist/services/product-modifiers-service.d.ts +6 -6
  53. package/cjs/dist/services/product-modifiers-service.js +17 -21
  54. package/cjs/dist/services/product-service.d.ts +8 -8
  55. package/cjs/dist/services/product-service.js +22 -26
  56. package/cjs/dist/services/related-products-service.d.ts +5 -5
  57. package/cjs/dist/services/related-products-service.js +9 -13
  58. package/cjs/dist/services/selected-variant-service.d.ts +11 -8
  59. package/cjs/dist/services/selected-variant-service.js +73 -90
  60. package/cjs/dist/services/social-sharing-service.d.ts +2 -9
  61. package/cjs/dist/services/social-sharing-service.js +48 -60
  62. package/cjs/dist/services/sort-service.d.ts +3 -3
  63. package/cjs/dist/services/sort-service.js +14 -19
  64. package/cjs/dist/utils/index.js +6 -9
  65. package/cjs/dist/utils/url-params.js +5 -9
  66. package/dist/astro/actions/custom-checkout.d.ts +1 -1
  67. package/dist/astro/actions/custom-checkout.js +1 -1
  68. package/dist/astro/actions/index.d.ts +1 -1
  69. package/dist/astro/actions/index.js +1 -1
  70. package/dist/enums/index.d.ts +2 -2
  71. package/dist/enums/index.js +2 -2
  72. package/dist/react/BuyNow.js +4 -6
  73. package/dist/react/Category.d.ts +2 -2
  74. package/dist/react/Category.js +2 -2
  75. package/dist/react/Collection.d.ts +1 -1
  76. package/dist/react/Collection.js +20 -20
  77. package/dist/react/FilteredCollection.d.ts +6 -20
  78. package/dist/react/FilteredCollection.js +17 -35
  79. package/dist/react/PayNow.js +2 -4
  80. package/dist/react/Product.d.ts +3 -3
  81. package/dist/react/Product.js +2 -2
  82. package/dist/react/ProductActions.js +9 -10
  83. package/dist/react/ProductModifiers.d.ts +3 -1
  84. package/dist/react/ProductModifiers.js +14 -12
  85. package/dist/react/ProductVariantSelector.d.ts +1 -1
  86. package/dist/react/ProductVariantSelector.js +6 -8
  87. package/dist/react/RelatedProducts.d.ts +2 -2
  88. package/dist/react/RelatedProducts.js +25 -15
  89. package/dist/react/SelectedVariant.js +2 -2
  90. package/dist/react/SocialSharing.d.ts +2 -3
  91. package/dist/react/SocialSharing.js +24 -13
  92. package/dist/react/Sort.d.ts +4 -3
  93. package/dist/react/Sort.js +3 -4
  94. package/dist/react/index.d.ts +13 -13
  95. package/dist/react/index.js +13 -13
  96. package/dist/server-actions/index.d.ts +1 -1
  97. package/dist/server-actions/index.js +1 -1
  98. package/dist/services/buy-now-service.d.ts +44 -3
  99. package/dist/services/buy-now-service.js +7 -4
  100. package/dist/services/catalog-options-service.d.ts +3 -3
  101. package/dist/services/catalog-options-service.js +33 -30
  102. package/dist/services/catalog-price-range-service.d.ts +3 -3
  103. package/dist/services/catalog-price-range-service.js +18 -18
  104. package/dist/services/category-service.d.ts +7 -7
  105. package/dist/services/category-service.js +17 -15
  106. package/dist/services/collection-service.d.ts +8 -8
  107. package/dist/services/collection-service.js +80 -74
  108. package/dist/services/filter-service.d.ts +4 -4
  109. package/dist/services/filter-service.js +37 -48
  110. package/dist/services/index.d.ts +13 -2
  111. package/dist/services/index.js +13 -2
  112. package/dist/services/pay-now-service.d.ts +4 -3
  113. package/dist/services/pay-now-service.js +1 -1
  114. package/dist/services/product-modifiers-service.d.ts +6 -6
  115. package/dist/services/product-modifiers-service.js +13 -13
  116. package/dist/services/product-service.d.ts +8 -8
  117. package/dist/services/product-service.js +19 -19
  118. package/dist/services/related-products-service.d.ts +5 -5
  119. package/dist/services/related-products-service.js +6 -6
  120. package/dist/services/selected-variant-service.d.ts +11 -8
  121. package/dist/services/selected-variant-service.js +71 -85
  122. package/dist/services/social-sharing-service.d.ts +2 -9
  123. package/dist/services/social-sharing-service.js +29 -37
  124. package/dist/services/sort-service.d.ts +3 -3
  125. package/dist/services/sort-service.js +8 -10
  126. package/dist/utils/url-params.js +4 -4
  127. package/package.json +5 -5
  128. package/cjs/dist/services/product-media-gallery-service.d.ts +0 -25
  129. package/cjs/dist/services/product-media-gallery-service.js +0 -105
  130. package/dist/services/product-media-gallery-service.d.ts +0 -25
  131. package/dist/services/product-media-gallery-service.js +0 -101
@@ -1,4 +1,4 @@
1
- import { type CustomLineItemCheckoutOptions } from "@wix/headless-stores/server-actions";
1
+ import { type CustomLineItemCheckoutOptions } from "../../server-actions/index.js";
2
2
  /**
3
3
  * Creates an Astro action factory for custom checkout functionality with line items.
4
4
  *
@@ -45,4 +45,6 @@ import { type CustomLineItemCheckoutOptions } from "@wix/headless-stores/server-
45
45
  * @see {@link https://docs.astro.build/en/guides/actions/} Astro Actions Documentation
46
46
  * @see {@link https://dev.wix.com/docs/sdk/headless/api-reference/stores/checkout} Wix Stores Checkout API
47
47
  */
48
- export declare const customCheckoutActionFactory: (factoryOpts: CustomLineItemCheckoutOptions) => any;
48
+ export declare const customCheckoutActionFactory: (factoryOpts: CustomLineItemCheckoutOptions) => ((input?: any) => Promise<import("astro:actions").SafeResult<never, string>>) & {
49
+ orThrow: (input?: any) => Promise<string>;
50
+ } & string;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.customCheckoutActionFactory = void 0;
4
1
  /// <reference types="astro/env" />
5
2
  // @ts-ignore
6
- const astro_actions_1 = require("astro:actions");
7
- const server_actions_1 = require("@wix/headless-stores/server-actions");
3
+ import { defineAction } from "astro:actions";
4
+ import { getCustomLineItemCheckoutURLFactory, } from "../../server-actions/index.js";
8
5
  /**
9
6
  * Creates an Astro action factory for custom checkout functionality with line items.
10
7
  *
@@ -51,7 +48,6 @@ const server_actions_1 = require("@wix/headless-stores/server-actions");
51
48
  * @see {@link https://docs.astro.build/en/guides/actions/} Astro Actions Documentation
52
49
  * @see {@link https://dev.wix.com/docs/sdk/headless/api-reference/stores/checkout} Wix Stores Checkout API
53
50
  */
54
- const customCheckoutActionFactory = (factoryOpts) => (0, astro_actions_1.defineAction)({
55
- handler: () => (0, server_actions_1.getCustomLineItemCheckoutURLFactory)(factoryOpts)(),
51
+ export const customCheckoutActionFactory = (factoryOpts) => defineAction({
52
+ handler: () => getCustomLineItemCheckoutURLFactory(factoryOpts)(),
56
53
  });
57
- exports.customCheckoutActionFactory = customCheckoutActionFactory;
@@ -1 +1 @@
1
- export * from "./custom-checkout";
1
+ export * from "./custom-checkout.js";
@@ -1,17 +1 @@
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("./custom-checkout"), exports);
1
+ export * from "./custom-checkout.js";
@@ -1,2 +1,2 @@
1
- export * from './sort-enums';
2
- export * from './social-platform-enums';
1
+ export * from "./sort-enums.js";
2
+ export * from "./social-platform-enums.js";
@@ -1,18 +1,2 @@
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);
1
+ export * from "./sort-enums.js";
2
+ export * from "./social-platform-enums.js";
@@ -1,13 +1,10 @@
1
- "use strict";
2
1
  /**
3
2
  * Business logic enums for social sharing platforms (headless layer)
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SocialPlatformShareUrl = exports.SocialPlatform = void 0;
7
4
  /**
8
5
  * Enum for social sharing platforms (business identifiers)
9
6
  */
10
- var SocialPlatform;
7
+ export var SocialPlatform;
11
8
  (function (SocialPlatform) {
12
9
  SocialPlatform["FACEBOOK"] = "facebook";
13
10
  SocialPlatform["TWITTER"] = "twitter";
@@ -16,15 +13,15 @@ var SocialPlatform;
16
13
  SocialPlatform["EMAIL"] = "email";
17
14
  SocialPlatform["CLIPBOARD"] = "clipboard";
18
15
  SocialPlatform["NATIVE"] = "native";
19
- })(SocialPlatform || (exports.SocialPlatform = SocialPlatform = {}));
16
+ })(SocialPlatform || (SocialPlatform = {}));
20
17
  /**
21
18
  * Enum for social platform share URLs (business logic)
22
19
  */
23
- var SocialPlatformShareUrl;
20
+ export var SocialPlatformShareUrl;
24
21
  (function (SocialPlatformShareUrl) {
25
22
  SocialPlatformShareUrl["FACEBOOK"] = "https://www.facebook.com/sharer/sharer.php";
26
23
  SocialPlatformShareUrl["TWITTER"] = "https://twitter.com/intent/tweet";
27
24
  SocialPlatformShareUrl["LINKEDIN"] = "https://www.linkedin.com/sharing/share-offsite/";
28
25
  SocialPlatformShareUrl["WHATSAPP"] = "https://wa.me/";
29
26
  SocialPlatformShareUrl["EMAIL"] = "mailto:";
30
- })(SocialPlatformShareUrl || (exports.SocialPlatformShareUrl = SocialPlatformShareUrl = {}));
27
+ })(SocialPlatformShareUrl || (SocialPlatformShareUrl = {}));
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_SORT_TYPE = exports.SortType = void 0;
4
1
  /**
5
2
  * Enum for sort types used in the store
6
3
  * Note: Cannot use SDK SortType as it's for aggregations (COUNT/VALUE)
7
4
  * while this enum represents user-facing sort options
8
5
  */
9
- var SortType;
6
+ export var SortType;
10
7
  (function (SortType) {
11
8
  SortType["NEWEST"] = "newest";
12
9
  SortType["NAME_ASC"] = "name_asc";
@@ -14,8 +11,8 @@ var SortType;
14
11
  SortType["PRICE_ASC"] = "price_asc";
15
12
  SortType["PRICE_DESC"] = "price_desc";
16
13
  SortType["RECOMMENDED"] = "recommended";
17
- })(SortType || (exports.SortType = SortType = {}));
14
+ })(SortType || (SortType = {}));
18
15
  /**
19
16
  * Default sort type
20
17
  */
21
- exports.DEFAULT_SORT_TYPE = SortType.NEWEST;
18
+ export const DEFAULT_SORT_TYPE = SortType.NEWEST;
@@ -1,10 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuyNow = BuyNow;
4
- const services_manager_react_1 = require("@wix/services-manager-react");
5
- const buy_now_service_1 = require("../services/buy-now-service");
6
- ;
7
- ;
1
+ import { useService } from "@wix/services-manager-react";
2
+ import { BuyNowServiceDefinition } from "../services/buy-now-service.js";
8
3
  /**
9
4
  * A headless component that provides buy now functionality using the render props pattern.
10
5
  *
@@ -32,8 +27,8 @@ const buy_now_service_1 = require("../services/buy-now-service");
32
27
  * ```
33
28
  * @component
34
29
  */
35
- function BuyNow(props) {
36
- const { redirectToCheckout, loadingSignal, productName, errorSignal, price, currency, inStock, preOrderAvailable, } = (0, services_manager_react_1.useService)(buy_now_service_1.BuyNowServiceDefinition);
30
+ export function BuyNow(props) {
31
+ const { redirectToCheckout, loadingSignal, productName, errorSignal, price, currency, inStockSignal, preOrderAvailableSignal, } = useService(BuyNowServiceDefinition);
37
32
  return props.children({
38
33
  isLoading: loadingSignal.get(),
39
34
  error: errorSignal.get(),
@@ -41,7 +36,7 @@ function BuyNow(props) {
41
36
  redirectToCheckout,
42
37
  price,
43
38
  currency,
44
- inStock,
45
- preOrderAvailable,
39
+ inStock: inStockSignal.get(),
40
+ preOrderAvailable: preOrderAvailableSignal.get(),
46
41
  });
47
42
  }
@@ -1,5 +1,5 @@
1
- import { type Category } from '@wix/auto_sdk_categories_categories';
2
- import React, { type ReactNode } from 'react';
1
+ import { type Category } from "@wix/auto_sdk_categories_categories";
2
+ import React, { type ReactNode } from "react";
3
3
  export interface CategoryListProps {
4
4
  children: (data: {
5
5
  categories: Category[];
@@ -1,22 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.List = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const services_manager_react_1 = require("@wix/services-manager-react");
6
- const category_service_1 = require("../services/category-service");
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { useService } from "@wix/services-manager-react";
3
+ import { CategoryServiceDefinition } from "../services/category-service.js";
7
4
  /**
8
5
  * Headless component for displaying a list of categories
9
6
  *
10
7
  * @component
11
8
  */
12
- const List = ({ children }) => {
13
- const service = (0, services_manager_react_1.useService)(category_service_1.CategoryServiceDefinition);
9
+ export const List = ({ children }) => {
10
+ const service = useService(CategoryServiceDefinition);
14
11
  const categories = service.categories.get();
15
12
  const selectedCategory = service.selectedCategory.get();
16
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
13
+ return (_jsx(_Fragment, { children: children({
17
14
  selectedCategory,
18
15
  categories,
19
16
  setSelectedCategory: service.setSelectedCategory,
20
17
  }) }));
21
18
  };
22
- exports.List = List;
@@ -1,4 +1,4 @@
1
- import { type V3Product } from '@wix/auto_sdk_stores_products-v-3';
1
+ import { type V3Product } from "@wix/auto_sdk_stores_products-v-3";
2
2
  /**
3
3
  * Props for Grid headless component
4
4
  */
@@ -1,23 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Actions = exports.Header = exports.LoadMore = exports.Item = exports.Grid = void 0;
4
- const services_manager_react_1 = require("@wix/services-manager-react");
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");
1
+ import { useService } from "@wix/services-manager-react";
2
+ import { CollectionServiceDefinition } from "../services/collection-service.js";
3
+ import { InventoryAvailabilityStatus, } from "@wix/auto_sdk_stores_products-v-3";
7
4
  /**
8
5
  * Headless component for product grid
9
6
  *
10
7
  * @component
11
8
  */
12
- const Grid = (props) => {
13
- const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
9
+ export const Grid = (props) => {
10
+ const service = useService(CollectionServiceDefinition);
14
11
  // Debug logging to help identify service issues
15
12
  if (!service) {
16
- console.error('CollectionService is undefined');
13
+ console.error("CollectionService is undefined");
17
14
  return props.children({
18
15
  products: [],
19
16
  isLoading: false,
20
- error: 'Service not available',
17
+ error: "Service not available",
21
18
  isEmpty: true,
22
19
  totalProducts: 0,
23
20
  hasProducts: false,
@@ -40,42 +37,41 @@ const Grid = (props) => {
40
37
  });
41
38
  }
42
39
  catch (err) {
43
- console.error('Error accessing service properties:', err);
40
+ console.error("Error accessing service properties:", err);
44
41
  return props.children({
45
42
  products: [],
46
43
  isLoading: false,
47
- error: 'Failed to load products',
44
+ error: "Failed to load products",
48
45
  isEmpty: true,
49
46
  totalProducts: 0,
50
47
  hasProducts: false,
51
48
  });
52
49
  }
53
50
  };
54
- exports.Grid = Grid;
55
51
  /**
56
52
  * Headless component for individual product item
57
53
  *
58
54
  * @component
59
55
  */
60
- const Item = (props) => {
56
+ export const Item = (props) => {
61
57
  const { product } = props;
62
58
  // Use actual v3 API structure based on real data
63
59
  // Images are in media.main.image, not media.itemsInfo.items
64
60
  const image = product?.media?.main?.image || null;
65
61
  // Create formatted price since formattedAmount is not available
66
62
  const rawAmount = product.actualPriceRange?.minValue?.amount;
67
- const price = rawAmount ? `$${rawAmount}` : '$0.00';
63
+ const price = rawAmount ? `$${rawAmount}` : "$0.00";
68
64
  // Create formatted compare-at price
69
65
  const rawCompareAmount = product.compareAtPriceRange?.minValue?.amount;
70
66
  const compareAtPrice = rawCompareAmount ? `$${rawCompareAmount}` : null;
71
67
  const availabilityStatus = product.inventory?.availabilityStatus;
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 : '';
68
+ const available = availabilityStatus === InventoryAvailabilityStatus.IN_STOCK ||
69
+ availabilityStatus === InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK;
70
+ const description = typeof product.description === "string" ? product.description : "";
75
71
  return props.children({
76
- id: product._id || '',
77
- title: product.name || '',
78
- slug: product.slug || '',
72
+ id: product._id || "",
73
+ title: product.name || "",
74
+ slug: product.slug || "",
79
75
  image,
80
76
  price,
81
77
  compareAtPrice,
@@ -84,18 +80,17 @@ const Item = (props) => {
84
80
  href: `/store/products/${product.slug}`,
85
81
  });
86
82
  };
87
- exports.Item = Item;
88
83
  /**
89
84
  * Headless component for load more products functionality
90
85
  * Note: V3 API uses simplified loading without traditional pagination
91
86
  *
92
87
  * @component
93
88
  */
94
- const LoadMore = (props) => {
95
- const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
89
+ export const LoadMore = (props) => {
90
+ const service = useService(CollectionServiceDefinition);
96
91
  // Error handling for undefined service
97
92
  if (!service) {
98
- console.error('CollectionService is undefined in LoadMore');
93
+ console.error("CollectionService is undefined in LoadMore");
99
94
  return props.children({
100
95
  loadMore: async () => { },
101
96
  refresh: async () => { },
@@ -120,7 +115,7 @@ const LoadMore = (props) => {
120
115
  });
121
116
  }
122
117
  catch (err) {
123
- console.error('Error in LoadMore:', err);
118
+ console.error("Error in LoadMore:", err);
124
119
  return props.children({
125
120
  loadMore: async () => { },
126
121
  refresh: async () => { },
@@ -131,17 +126,16 @@ const LoadMore = (props) => {
131
126
  });
132
127
  }
133
128
  };
134
- exports.LoadMore = LoadMore;
135
129
  /**
136
130
  * Headless component for collection header with product count
137
131
  *
138
132
  * @component
139
133
  */
140
- const Header = (props) => {
141
- const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
134
+ export const Header = (props) => {
135
+ const service = useService(CollectionServiceDefinition);
142
136
  // Error handling for undefined service
143
137
  if (!service) {
144
- console.error('CollectionService is undefined in Header');
138
+ console.error("CollectionService is undefined in Header");
145
139
  return props.children({
146
140
  totalProducts: 0,
147
141
  isLoading: false,
@@ -159,7 +153,7 @@ const Header = (props) => {
159
153
  });
160
154
  }
161
155
  catch (err) {
162
- console.error('Error in Header:', err);
156
+ console.error("Error in Header:", err);
163
157
  return props.children({
164
158
  totalProducts: 0,
165
159
  isLoading: false,
@@ -167,23 +161,22 @@ const Header = (props) => {
167
161
  });
168
162
  }
169
163
  };
170
- exports.Header = Header;
171
164
  /**
172
165
  * Headless component for collection actions (refresh, load more)
173
166
  * Replaces traditional pagination for V3 API
174
167
  *
175
168
  * @component
176
169
  */
177
- const Actions = (props) => {
178
- const service = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
170
+ export const Actions = (props) => {
171
+ const service = useService(CollectionServiceDefinition);
179
172
  // Error handling for undefined service
180
173
  if (!service) {
181
- console.error('CollectionService is undefined in Actions');
174
+ console.error("CollectionService is undefined in Actions");
182
175
  return props.children({
183
176
  refresh: async () => { },
184
177
  loadMore: async () => { },
185
178
  isLoading: false,
186
- error: 'Service not available',
179
+ error: "Service not available",
187
180
  });
188
181
  }
189
182
  try {
@@ -197,13 +190,12 @@ const Actions = (props) => {
197
190
  });
198
191
  }
199
192
  catch (err) {
200
- console.error('Error in Actions:', err);
193
+ console.error("Error in Actions:", err);
201
194
  return props.children({
202
195
  refresh: async () => { },
203
196
  loadMore: async () => { },
204
197
  isLoading: false,
205
- error: 'Failed to load actions',
198
+ error: "Failed to load actions",
206
199
  });
207
200
  }
208
201
  };
209
- exports.Actions = Actions;
@@ -1,21 +1,7 @@
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';
1
+ import React, { type ReactNode } from "react";
2
+ import { type AvailableOptions, type FilterServiceAPI, type Filter } from "../services/filter-service.js";
3
+ import { type V3Product } from "@wix/auto_sdk_stores_products-v-3";
5
4
  export type { AvailableOptions, Filter, FilterServiceAPI };
6
- export interface FilteredCollectionProviderProps {
7
- children: ReactNode;
8
- }
9
- /**
10
- * Headless component for providing a filtered collection
11
- *
12
- * @component
13
- */
14
- export declare const Provider: React.FC<FilteredCollectionProviderProps>;
15
- export declare const useFilteredCollection: () => {
16
- filter: FilterServiceAPI | null;
17
- collection: CollectionServiceAPI | null;
18
- };
19
5
  export interface FiltersLoadingProps {
20
6
  children: (data: {
21
7
  isFullyLoaded: boolean;
@@ -57,7 +43,7 @@ export interface FilteredItemProps {
57
43
  }) => ReactNode;
58
44
  }
59
45
  /**
60
- * Headless component for displaying an individual product item
46
+ * Headless component for displaying a filtered product item
61
47
  *
62
48
  * @component
63
49
  */
@@ -73,7 +59,7 @@ export interface FilteredLoadMoreProps {
73
59
  }) => ReactNode;
74
60
  }
75
61
  /**
76
- * Headless component for displaying a load more button
62
+ * Headless component for load more filtered products functionality
77
63
  *
78
64
  * @component
79
65
  */
@@ -89,7 +75,7 @@ export interface FilteredFiltersProps {
89
75
  }) => ReactNode;
90
76
  }
91
77
  /**
92
- * Headless component for displaying a filters component
78
+ * Headless component for product filters with available options
93
79
  *
94
80
  * @component
95
81
  */
@@ -1,57 +1,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Filters = exports.LoadMore = exports.Item = exports.Grid = exports.FiltersLoading = exports.useFilteredCollection = exports.Provider = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const filter_service_1 = require("../services/filter-service");
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");
9
- const collection_service_1 = require("../services/collection-service");
10
- const FilteredCollectionContext = (0, react_1.createContext)({ filter: null, collection: null });
11
- /**
12
- * Headless component for providing a filtered collection
13
- *
14
- * @component
15
- */
16
- const Provider = ({ children, }) => {
17
- const filter = (0, services_manager_react_1.useService)(filter_service_1.FilterServiceDefinition);
18
- const collection = (0, services_manager_react_1.useService)(collection_service_1.CollectionServiceDefinition);
19
- return ((0, jsx_runtime_1.jsx)(FilteredCollectionContext.Provider, { value: { filter, collection }, children: children }));
20
- };
21
- exports.Provider = Provider;
22
- const useFilteredCollection = () => {
23
- const context = (0, react_1.useContext)(FilteredCollectionContext);
24
- if (!context) {
25
- throw new Error('useFilteredCollection must be used within a FilteredCollectionProvider');
26
- }
27
- return context;
28
- };
29
- exports.useFilteredCollection = useFilteredCollection;
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { useService } from "@wix/services-manager-react";
3
+ import { CollectionServiceDefinition } from "../services/collection-service.js";
4
+ import { FilterServiceDefinition, } from "../services/filter-service.js";
5
+ import { InventoryAvailabilityStatus, } from "@wix/auto_sdk_stores_products-v-3";
30
6
  /**
31
7
  * Headless component for displaying a loading state for filters
32
8
  *
33
9
  * @component
34
10
  */
35
- const FiltersLoading = ({ children }) => {
36
- const { filter } = (0, exports.useFilteredCollection)();
11
+ export const FiltersLoading = ({ children }) => {
12
+ const filter = useService(FilterServiceDefinition);
37
13
  const isFullyLoaded = filter.isFullyLoaded.get();
38
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({ isFullyLoaded }) });
14
+ return _jsx(_Fragment, { children: children({ isFullyLoaded }) });
39
15
  };
40
- exports.FiltersLoading = FiltersLoading;
41
16
  /**
42
17
  * Headless component for displaying a grid of filtered products
43
18
  *
44
19
  * @component
45
20
  */
46
- const Grid = ({ children }) => {
47
- const { collection } = (0, exports.useFilteredCollection)();
21
+ export const Grid = ({ children }) => {
22
+ const collection = useService(CollectionServiceDefinition);
48
23
  const products = collection.products.get() || [];
49
24
  const totalProducts = collection.totalProducts.get();
50
25
  const isLoading = collection.isLoading.get();
51
26
  const error = collection.error.get();
52
27
  const hasProducts = collection.hasProducts.get();
53
28
  const hasMoreProducts = collection.hasMoreProducts.get();
54
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
29
+ return (_jsx(_Fragment, { children: children({
55
30
  products,
56
31
  isLoading,
57
32
  error,
@@ -60,35 +35,34 @@ const Grid = ({ children }) => {
60
35
  hasMoreProducts,
61
36
  }) }));
62
37
  };
63
- exports.Grid = Grid;
64
38
  /**
65
- * Headless component for displaying an individual product item
39
+ * Headless component for displaying a filtered product item
66
40
  *
67
41
  * @component
68
42
  */
69
- const Item = ({ product, children }) => {
43
+ export const Item = ({ product, children }) => {
70
44
  // Safe conversion of product data with type safety guards
71
- const title = String(product.name || '');
45
+ const title = String(product.name || "");
72
46
  const image = product.media?.main?.image || null;
73
- const imageAltText = product.media?.main?.altText || '';
47
+ const imageAltText = product.media?.main?.altText || "";
74
48
  const price = product.actualPriceRange?.minValue?.formattedAmount ||
75
49
  product.actualPriceRange?.maxValue?.formattedAmount ||
76
50
  (product.actualPriceRange?.minValue?.amount
77
51
  ? `$${product.actualPriceRange.minValue.amount}`
78
- : '$0.00');
52
+ : "$0.00");
79
53
  // Add compare at price
80
54
  const compareAtPrice = product.compareAtPriceRange?.minValue?.formattedAmount ||
81
55
  (product.compareAtPriceRange?.minValue?.amount
82
56
  ? `$${product.compareAtPriceRange.minValue.amount}`
83
57
  : null);
84
58
  const availabilityStatus = product.inventory?.availabilityStatus;
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 || '');
59
+ const available = availabilityStatus === InventoryAvailabilityStatus.IN_STOCK ||
60
+ availabilityStatus === InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK;
61
+ const slug = String(product.slug || product._id || "");
88
62
  const description = product.plainDescription
89
63
  ? String(product.plainDescription)
90
64
  : undefined;
91
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
65
+ return (_jsx(_Fragment, { children: children({
92
66
  title,
93
67
  image,
94
68
  imageAltText,
@@ -99,21 +73,20 @@ const Item = ({ product, children }) => {
99
73
  description,
100
74
  }) }));
101
75
  };
102
- exports.Item = Item;
103
76
  /**
104
- * Headless component for displaying a load more button
77
+ * Headless component for load more filtered products functionality
105
78
  *
106
79
  * @component
107
80
  */
108
- const LoadMore = ({ children }) => {
109
- const { collection } = (0, exports.useFilteredCollection)();
81
+ export const LoadMore = ({ children }) => {
82
+ const collection = useService(CollectionServiceDefinition);
110
83
  const loadMore = collection.loadMore;
111
84
  const refresh = collection.refresh;
112
85
  const isLoading = collection.isLoading.get();
113
86
  const hasProducts = collection.hasProducts.get();
114
87
  const totalProducts = collection.totalProducts.get();
115
88
  const hasMoreProducts = collection.hasMoreProducts.get();
116
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
89
+ return (_jsx(_Fragment, { children: children({
117
90
  loadMore,
118
91
  refresh,
119
92
  isLoading,
@@ -122,14 +95,14 @@ const LoadMore = ({ children }) => {
122
95
  hasMoreProducts,
123
96
  }) }));
124
97
  };
125
- exports.LoadMore = LoadMore;
126
98
  /**
127
- * Headless component for displaying a filters component
99
+ * Headless component for product filters with available options
128
100
  *
129
101
  * @component
130
102
  */
131
- const Filters = ({ children }) => {
132
- const { collection, filter } = (0, exports.useFilteredCollection)();
103
+ export const Filters = ({ children }) => {
104
+ const collection = useService(CollectionServiceDefinition);
105
+ const filter = useService(FilterServiceDefinition);
133
106
  const applyFilters = filter.applyFilters;
134
107
  const clearFilters = filter.clearFilters;
135
108
  const currentFilters = filter.currentFilters.get();
@@ -138,7 +111,7 @@ const Filters = ({ children }) => {
138
111
  const isFiltered = currentFilters.priceRange.min !== availableOptions.priceRange.min ||
139
112
  currentFilters.priceRange.max !== availableOptions.priceRange.max ||
140
113
  Object.keys(currentFilters.selectedOptions).length > 0;
141
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
114
+ return (_jsx(_Fragment, { children: children({
142
115
  applyFilters,
143
116
  clearFilters,
144
117
  currentFilters,
@@ -147,4 +120,3 @@ const Filters = ({ children }) => {
147
120
  isFiltered,
148
121
  }) }));
149
122
  };
150
- exports.Filters = Filters;