@wix/headless-stores 0.0.12 → 0.0.15

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 +6 -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,10 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PayNow = PayNow;
4
- const services_manager_react_1 = require("@wix/services-manager-react");
5
- const pay_now_service_1 = require("../services/pay-now-service");
6
- ;
7
- ;
1
+ import { useService } from "@wix/services-manager-react";
2
+ import { PayNowServiceDefinition } from "../services/pay-now-service.js";
8
3
  /**
9
4
  * A headless component that provides pay now functionality using the render props pattern.
10
5
  *
@@ -28,8 +23,8 @@ const pay_now_service_1 = require("../services/pay-now-service");
28
23
  * ```
29
24
  * @component
30
25
  */
31
- function PayNow(props) {
32
- const { redirectToCheckout, loadingSignal, errorSignal, } = (0, services_manager_react_1.useService)(pay_now_service_1.PayNowServiceDefinition);
26
+ export function PayNow(props) {
27
+ const { redirectToCheckout, loadingSignal, errorSignal } = useService(PayNowServiceDefinition);
33
28
  return props.children({
34
29
  isLoading: loadingSignal.get(),
35
30
  error: errorSignal.get(),
@@ -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 ProductName headless component
4
4
  */
@@ -31,9 +31,9 @@ export interface ProductDescriptionProps {
31
31
  */
32
32
  export interface ProductDescriptionRenderProps {
33
33
  /** Product description (may contain HTML) */
34
- description: NonNullable<V3Product['description']>;
34
+ description: NonNullable<V3Product["description"]>;
35
35
  /** Product plain description */
36
- plainDescription: NonNullable<V3Product['plainDescription']>;
36
+ plainDescription: NonNullable<V3Product["plainDescription"]>;
37
37
  }
38
38
  /**
39
39
  * Headless component for product description display
@@ -1,29 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Description = exports.Name = void 0;
4
- const services_manager_react_1 = require("@wix/services-manager-react");
5
- const product_service_1 = require("../services/product-service");
1
+ import { useService } from "@wix/services-manager-react";
2
+ import { ProductServiceDefinition } from "../services/product-service.js";
6
3
  /**
7
4
  * Headless component for product name display
8
5
  *
9
6
  * @component
10
7
  */
11
- const Name = (props) => {
12
- const service = (0, services_manager_react_1.useService)(product_service_1.ProductServiceDefinition);
8
+ export const Name = (props) => {
9
+ const service = useService(ProductServiceDefinition);
13
10
  const product = service.product.get();
14
11
  const name = product.name;
15
12
  return props.children({
16
13
  name,
17
14
  });
18
15
  };
19
- exports.Name = Name;
20
16
  /**
21
17
  * Headless component for product description display
22
18
  *
23
19
  * @component
24
20
  */
25
- const Description = (props) => {
26
- const service = (0, services_manager_react_1.useService)(product_service_1.ProductServiceDefinition);
21
+ export const Description = (props) => {
22
+ const service = useService(ProductServiceDefinition);
27
23
  const product = service.product.get();
28
24
  const descriptionRichContent = product.description;
29
25
  const plainDescription = product.plainDescription;
@@ -32,4 +28,3 @@ const Description = (props) => {
32
28
  plainDescription: plainDescription,
33
29
  });
34
30
  };
35
- exports.Description = Description;
@@ -1,23 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Actions = void 0;
4
- const services_manager_react_1 = require("@wix/services-manager-react");
5
- const selected_variant_service_1 = require("../services/selected-variant-service");
6
- const product_modifiers_service_1 = require("../services/product-modifiers-service");
1
+ import { useService } from "@wix/services-manager-react";
2
+ import { SelectedVariantServiceDefinition } from "../services/selected-variant-service.js";
3
+ import { ProductModifiersServiceDefinition } from "../services/product-modifiers-service.js";
4
+ import { CurrentCartServiceDefinition } from "@wix/headless-ecom/services";
7
5
  /**
8
6
  * Headless component for product actions (add to cart, buy now)
9
7
  *
10
8
  * @component
11
9
  */
12
- const Actions = (props) => {
13
- const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
14
- // const cartService = useService(CurrentCartServiceDefinition) as ServiceAPI<
15
- // typeof CurrentCartServiceDefinition
16
- // >;
10
+ export const Actions = (props) => {
11
+ const variantService = useService(SelectedVariantServiceDefinition);
12
+ const cartService = useService(CurrentCartServiceDefinition);
17
13
  // Try to get modifiers service - it may not exist for all products
18
14
  let modifiersService = null;
19
15
  try {
20
- modifiersService = (0, services_manager_react_1.useService)(product_modifiers_service_1.ProductModifiersServiceDefinition);
16
+ modifiersService = useService(ProductModifiersServiceDefinition);
21
17
  }
22
18
  catch {
23
19
  // Modifiers service not available for this product
@@ -52,19 +48,19 @@ const Actions = (props) => {
52
48
  const onBuyNow = async () => {
53
49
  try {
54
50
  // Clear the cart first
55
- // await cartService.clearCart();
51
+ await cartService.clearCart();
56
52
  // Add the product to cart
57
53
  await onAddToCart();
58
54
  // Proceed to checkout
59
- // await cartService.proceedToCheckout();
55
+ await cartService.proceedToCheckout();
60
56
  }
61
57
  catch (error) {
62
- console.error('Buy now failed:', error);
58
+ console.error("Buy now failed:", error);
63
59
  throw error;
64
60
  }
65
61
  };
66
62
  const onOpenCart = () => {
67
- // cartService.openCart();
63
+ cartService.openCart();
68
64
  };
69
65
  return props.children({
70
66
  onAddToCart,
@@ -80,4 +76,3 @@ const Actions = (props) => {
80
76
  availableQuantity,
81
77
  });
82
78
  };
83
- exports.Actions = Actions;
@@ -1,4 +1,4 @@
1
- import { type ConnectedModifier, type ConnectedModifierChoice } from '@wix/auto_sdk_stores_products-v-3';
1
+ import { type ConnectedModifier, type ConnectedModifierChoice } from "@wix/auto_sdk_stores_products-v-3";
2
2
  /**
3
3
  * Props for Modifiers headless component
4
4
  */
@@ -21,6 +21,8 @@ export interface ModifiersRenderProps {
21
21
  }
22
22
  /**
23
23
  * Headless component for all product modifiers
24
+ *
25
+ * @component
24
26
  */
25
27
  export declare const Modifiers: (props: ModifiersProps) => import("react").ReactNode;
26
28
  /**
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ToggleFreeText = exports.FreeText = exports.Choice = exports.Modifier = exports.Modifiers = void 0;
4
- const react_1 = require("react");
5
- const services_manager_react_1 = require("@wix/services-manager-react");
6
- const product_modifiers_service_1 = require("../services/product-modifiers-service");
7
- const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
1
+ import { useState } from "react";
2
+ import { useService } from "@wix/services-manager-react";
3
+ import { ProductModifiersServiceDefinition } from "../services/product-modifiers-service.js";
4
+ import { ModifierRenderType, } from "@wix/auto_sdk_stores_products-v-3";
8
5
  /**
9
6
  * Custom hook to safely get the modifiers service
10
7
  */
11
8
  function useModifiersService() {
12
9
  try {
13
- return (0, services_manager_react_1.useService)(product_modifiers_service_1.ProductModifiersServiceDefinition);
10
+ return useService(ProductModifiersServiceDefinition);
14
11
  }
15
12
  catch {
16
13
  return null;
@@ -18,8 +15,10 @@ function useModifiersService() {
18
15
  }
19
16
  /**
20
17
  * Headless component for all product modifiers
18
+ *
19
+ * @component
21
20
  */
22
- const Modifiers = (props) => {
21
+ export const Modifiers = (props) => {
23
22
  const modifiersService = useModifiersService();
24
23
  if (!modifiersService) {
25
24
  return props.children({
@@ -40,21 +39,20 @@ const Modifiers = (props) => {
40
39
  areAllRequiredModifiersFilled,
41
40
  });
42
41
  };
43
- exports.Modifiers = Modifiers;
44
42
  /**
45
43
  * Headless component for a specific product modifier
46
44
  *
47
45
  * @component
48
46
  */
49
- const Modifier = (props) => {
47
+ export const Modifier = (props) => {
50
48
  const modifiersService = useModifiersService();
51
49
  const { modifier } = props;
52
- const name = modifier.name || '';
50
+ const name = modifier.name || "";
53
51
  const type = modifier.modifierRenderType;
54
52
  const mandatory = modifier.mandatory || false;
55
53
  const choices = modifier.choicesSettings?.choices || [];
56
54
  const hasChoices = choices.length > 0;
57
- const isFreeText = type === auto_sdk_stores_products_v_3_1.ModifierRenderType.FREE_TEXT;
55
+ const isFreeText = type === ModifierRenderType.FREE_TEXT;
58
56
  const freeTextSettings = modifier.freeTextSettings;
59
57
  const maxChars = freeTextSettings?.maxLength;
60
58
  const placeholder = freeTextSettings?.placeholder;
@@ -71,22 +69,21 @@ const Modifier = (props) => {
71
69
  placeholder,
72
70
  });
73
71
  };
74
- exports.Modifier = Modifier;
75
72
  /**
76
73
  * Headless component for individual modifier choice selection
77
74
  *
78
75
  * @component
79
76
  */
80
- const Choice = (props) => {
77
+ export const Choice = (props) => {
81
78
  const modifiersService = useModifiersService();
82
79
  const { modifier, choice } = props;
83
- const modifierName = modifier.name || '';
80
+ const modifierName = modifier.name || "";
84
81
  const renderType = modifier.modifierRenderType;
85
82
  // For TEXT_CHOICES, use choice.key; for SWATCH_CHOICES, use choice.name
86
- const choiceValue = renderType === auto_sdk_stores_products_v_3_1.ModifierRenderType.TEXT_CHOICES
87
- ? choice.key || choice.name || ''
88
- : choice.name || '';
89
- const value = choice.name || ''; // Display name is always choice.name
83
+ const choiceValue = renderType === ModifierRenderType.TEXT_CHOICES
84
+ ? choice.key || choice.name || ""
85
+ : choice.name || "";
86
+ const value = choice.name || ""; // Display name is always choice.name
90
87
  const description = choice.description;
91
88
  const colorCode = choice.colorCode;
92
89
  const selectedValue = modifiersService?.getModifierValue(modifierName);
@@ -104,22 +101,21 @@ const Choice = (props) => {
104
101
  colorCode,
105
102
  });
106
103
  };
107
- exports.Choice = Choice;
108
104
  /**
109
105
  * Headless component for free text modifier input
110
106
  *
111
107
  * @component
112
108
  */
113
- const FreeText = (props) => {
109
+ export const FreeText = (props) => {
114
110
  const modifiersService = useModifiersService();
115
111
  const { modifier } = props;
116
- const modifierName = modifier.name || '';
112
+ const modifierName = modifier.name || "";
117
113
  const mandatory = modifier.mandatory || false;
118
114
  const freeTextSettings = modifier.freeTextSettings;
119
115
  const maxChars = freeTextSettings?.maxLength;
120
116
  const placeholder = freeTextSettings?.placeholder;
121
117
  const selectedValue = modifiersService?.getModifierValue(modifierName);
122
- const value = selectedValue?.freeTextValue || '';
118
+ const value = selectedValue?.freeTextValue || "";
123
119
  const charCount = value.length;
124
120
  const isOverLimit = maxChars ? charCount > maxChars : false;
125
121
  const onChange = (newValue) => {
@@ -138,19 +134,18 @@ const FreeText = (props) => {
138
134
  modifierName,
139
135
  });
140
136
  };
141
- exports.FreeText = FreeText;
142
137
  /**
143
138
  * Headless component for toggling free text modifier input
144
139
  * Used for optional free text modifiers where a checkbox shows/hides the input
145
140
  *
146
141
  * @component
147
142
  */
148
- const ToggleFreeText = (props) => {
143
+ export const ToggleFreeText = (props) => {
149
144
  const modifiersService = useModifiersService();
150
145
  const { modifier } = props;
151
- const modifierName = modifier.name || '';
146
+ const modifierName = modifier.name || "";
152
147
  const mandatory = modifier.mandatory || false;
153
- const [isTextInputShown, setIsTextInputShown] = (0, react_1.useState)(mandatory);
148
+ const [isTextInputShown, setIsTextInputShown] = useState(mandatory);
154
149
  const onToggle = () => {
155
150
  const newState = !isTextInputShown;
156
151
  setIsTextInputShown(newState);
@@ -165,4 +160,3 @@ const ToggleFreeText = (props) => {
165
160
  modifierName,
166
161
  });
167
162
  };
168
- exports.ToggleFreeText = ToggleFreeText;
@@ -1,4 +1,4 @@
1
- import { type ConnectedOption, type ConnectedOptionChoice, InventoryAvailabilityStatus } from '@wix/auto_sdk_stores_products-v-3';
1
+ import { type ConnectedOption, type ConnectedOptionChoice, InventoryAvailabilityStatus } from "@wix/auto_sdk_stores_products-v-3";
2
2
  /**
3
3
  * Props for Options headless component
4
4
  */
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Reset = exports.Stock = exports.Choice = exports.Option = exports.Options = void 0;
4
- const services_manager_react_1 = require("@wix/services-manager-react");
5
- const selected_variant_service_1 = require("../services/selected-variant-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 { SelectedVariantServiceDefinition } from "../services/selected-variant-service.js";
3
+ import { InventoryAvailabilityStatus, } from "@wix/auto_sdk_stores_products-v-3";
7
4
  /**
8
5
  * Headless component for all product options
9
6
  *
10
7
  * @component
11
8
  */
12
- const Options = (props) => {
13
- const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
9
+ export const Options = (props) => {
10
+ const variantService = useService(SelectedVariantServiceDefinition);
14
11
  const selectedChoices = variantService.selectedChoices.get();
15
12
  const options = variantService.productOptions.get();
16
13
  return props.children({
@@ -19,17 +16,16 @@ const Options = (props) => {
19
16
  selectedChoices,
20
17
  });
21
18
  };
22
- exports.Options = Options;
23
19
  /**
24
20
  * Headless component for choices within a specific product option
25
21
  *
26
22
  * @component
27
23
  */
28
- const Option = (props) => {
29
- const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
24
+ export const Option = (props) => {
25
+ const variantService = useService(SelectedVariantServiceDefinition);
30
26
  const selectedChoices = variantService.selectedChoices.get();
31
27
  const { option } = props;
32
- const name = option.name || '';
28
+ const name = option.name || "";
33
29
  const choices = option.choicesSettings?.choices || [];
34
30
  const selectedValue = selectedChoices[name] || null;
35
31
  return props.children({
@@ -40,18 +36,17 @@ const Option = (props) => {
40
36
  hasChoices: choices.length > 0,
41
37
  });
42
38
  };
43
- exports.Option = Option;
44
39
  /**
45
40
  * Headless component for individual choice selection
46
41
  *
47
42
  * @component
48
43
  */
49
- const Choice = (props) => {
50
- const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
44
+ export const Choice = (props) => {
45
+ const variantService = useService(SelectedVariantServiceDefinition);
51
46
  const selectedChoices = variantService.selectedChoices.get();
52
47
  const { option, choice } = props;
53
- const optionName = option.name || '';
54
- const choiceValue = choice.name || '';
48
+ const optionName = option.name || "";
49
+ const choiceValue = choice.name || "";
55
50
  const isSelected = selectedChoices[optionName] === choiceValue;
56
51
  // Check if this choice is available based on current selections
57
52
  const isVisible = variantService.isChoiceAvailable(optionName, choiceValue);
@@ -79,26 +74,23 @@ const Choice = (props) => {
79
74
  choiceValue,
80
75
  });
81
76
  };
82
- exports.Choice = Choice;
83
77
  /**
84
78
  * Headless component for product stock status
85
79
  *
86
80
  * @component
87
81
  */
88
- const Stock = (props) => {
89
- const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
82
+ export const Stock = (props) => {
83
+ const variantService = useService(SelectedVariantServiceDefinition);
90
84
  const inStock = variantService.isInStock.get();
91
85
  const isPreOrderEnabled = variantService.isPreOrderEnabled.get();
92
86
  const trackInventory = variantService.trackQuantity.get();
93
87
  const currentVariantId = variantService.selectedVariantId.get();
94
88
  const availableQuantity = variantService.quantityAvailable.get();
95
89
  const selectedQuantity = variantService.selectedQuantity.get();
96
- // const currentVariant = variantService.currentVariant.get();
97
- // const allVariantsAreOutOfStock = variantService.IsAllVariantsAreOutOfStock();
98
90
  // Return raw availability status - UI components will handle display conversion
99
91
  const availabilityStatus = inStock
100
- ? auto_sdk_stores_products_v_3_1.InventoryAvailabilityStatus.IN_STOCK
101
- : auto_sdk_stores_products_v_3_1.InventoryAvailabilityStatus.OUT_OF_STOCK;
92
+ ? InventoryAvailabilityStatus.IN_STOCK
93
+ : InventoryAvailabilityStatus.OUT_OF_STOCK;
102
94
  const incrementQuantity = () => {
103
95
  variantService.incrementQuantity();
104
96
  };
@@ -117,14 +109,13 @@ const Stock = (props) => {
117
109
  decrementQuantity,
118
110
  });
119
111
  };
120
- exports.Stock = Stock;
121
112
  /**
122
113
  * Headless component for resetting variant selections
123
114
  *
124
115
  * @component
125
116
  */
126
- const Reset = (props) => {
127
- const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
117
+ export const Reset = (props) => {
118
+ const variantService = useService(SelectedVariantServiceDefinition);
128
119
  const selectedChoices = variantService.selectedChoices.get();
129
120
  const hasSelections = Object.keys(selectedChoices).length > 0;
130
121
  const onReset = () => {
@@ -135,4 +126,3 @@ const Reset = (props) => {
135
126
  hasSelections,
136
127
  });
137
128
  };
138
- exports.Reset = Reset;
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import { type V3Product } from '@wix/auto_sdk_stores_products-v-3';
1
+ import React from "react";
2
+ import { type V3Product } from "@wix/auto_sdk_stores_products-v-3";
3
3
  /**
4
4
  * Props for List headless component
5
5
  */
@@ -1,33 +1,37 @@
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.Item = exports.List = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const services_manager_react_1 = require("@wix/services-manager-react");
9
- const related_products_service_1 = require("../services/related-products-service");
10
- const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
1
+ import React from "react";
2
+ import { useService } from "@wix/services-manager-react";
3
+ import { RelatedProductsServiceDefinition } from "../services/related-products-service.js";
4
+ import { SignalsServiceDefinition } from "@wix/services-definitions/core-services/signals";
5
+ import { InventoryAvailabilityStatus, } from "@wix/auto_sdk_stores_products-v-3";
11
6
  /**
12
7
  * Headless component for displaying related products list
13
8
  *
14
9
  * @component
15
10
  */
16
- const List = (props) => {
17
- const service = (0, services_manager_react_1.useService)(related_products_service_1.RelatedProductsServiceDefinition);
18
- const [products, setProducts] = react_1.default.useState([]);
19
- const [isLoading, setIsLoading] = react_1.default.useState(false);
20
- const [error, setError] = react_1.default.useState(null);
21
- const [hasProducts, setHasProducts] = react_1.default.useState(false);
22
- react_1.default.useEffect(() => {
23
- const unsubscribes = [
24
- service.relatedProducts.subscribe(setProducts),
25
- service.isLoading.subscribe(setIsLoading),
26
- service.error.subscribe(setError),
27
- service.hasRelatedProducts.subscribe(setHasProducts),
11
+ export const List = (props) => {
12
+ const service = useService(RelatedProductsServiceDefinition);
13
+ const signalsService = useService(SignalsServiceDefinition);
14
+ const [products, setProducts] = React.useState([]);
15
+ const [isLoading, setIsLoading] = React.useState(false);
16
+ const [error, setError] = React.useState(null);
17
+ const [hasProducts, setHasProducts] = React.useState(false);
18
+ React.useEffect(() => {
19
+ const effects = [
20
+ signalsService.effect(() => {
21
+ setProducts(service.relatedProducts.get());
22
+ }),
23
+ signalsService.effect(() => {
24
+ setIsLoading(service.isLoading.get());
25
+ }),
26
+ signalsService.effect(() => {
27
+ setError(service.error.get());
28
+ }),
29
+ signalsService.effect(() => {
30
+ setHasProducts(service.hasRelatedProducts.get());
31
+ }),
28
32
  ];
29
- return () => unsubscribes.forEach(fn => fn());
30
- }, [service]);
33
+ return () => effects.forEach((dispose) => dispose());
34
+ }, [service, signalsService]);
31
35
  return props.children({
32
36
  products,
33
37
  isLoading,
@@ -36,29 +40,28 @@ const List = (props) => {
36
40
  refresh: service.refreshRelatedProducts,
37
41
  });
38
42
  };
39
- exports.List = List;
40
43
  /**
41
44
  * Headless component for individual related product item
42
45
  *
43
46
  * @component
44
47
  */
45
- const Item = (props) => {
48
+ export const Item = (props) => {
46
49
  const { product } = props;
47
- const title = product.name || 'Unknown Product';
50
+ const title = product.name || "Unknown Product";
48
51
  // Use actual v3 media structure - image is directly a string URL
49
52
  const image = product.media?.main?.image || null;
50
53
  // Create formatted price from raw amount since formattedAmount may not be available
51
54
  const rawPrice = product.actualPriceRange?.minValue?.amount;
52
- const price = rawPrice ? `$${rawPrice}` : 'Price unavailable';
55
+ const price = rawPrice ? `$${rawPrice}` : "Price unavailable";
53
56
  const availabilityStatus = product.inventory?.availabilityStatus;
54
- const available = availabilityStatus === auto_sdk_stores_products_v_3_1.InventoryAvailabilityStatus.IN_STOCK ||
55
- availabilityStatus === auto_sdk_stores_products_v_3_1.InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK;
57
+ const available = availabilityStatus === InventoryAvailabilityStatus.IN_STOCK ||
58
+ availabilityStatus === InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK;
56
59
  const href = `/store/example-2/${product.slug}`;
57
- const description = typeof product.description === 'string' ? product.description : '';
60
+ const description = typeof product.description === "string" ? product.description : "";
58
61
  const handleQuickAdd = () => {
59
62
  // This would typically add the product to cart
60
63
  // For now, we'll just log it
61
- console.log('Quick add:', product.name);
64
+ console.log("Quick add:", product.name);
62
65
  };
63
66
  return props.children({
64
67
  title,
@@ -70,4 +73,3 @@ const Item = (props) => {
70
73
  onQuickAdd: handleQuickAdd,
71
74
  });
72
75
  };
73
- exports.Item = Item;
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SKU = exports.Price = exports.Details = void 0;
4
- const services_manager_react_1 = require("@wix/services-manager-react");
5
- const selected_variant_service_1 = require("../services/selected-variant-service");
1
+ import { useService } from "@wix/services-manager-react";
2
+ import { SelectedVariantServiceDefinition } from "../services/selected-variant-service.js";
6
3
  /**
7
4
  * Headless component for selected variant details display
8
5
  *
9
6
  * @component
10
7
  */
11
- const Details = (props) => {
12
- const selectedVariantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
8
+ export const Details = (props) => {
9
+ const selectedVariantService = useService(SelectedVariantServiceDefinition);
13
10
  const selectedVariant = selectedVariantService.currentVariant?.get();
14
11
  let sku = selectedVariant?.sku || null;
15
12
  let weight = selectedVariant?.physicalProperties?.weight?.toString() || null;
@@ -18,14 +15,13 @@ const Details = (props) => {
18
15
  weight,
19
16
  });
20
17
  };
21
- exports.Details = Details;
22
18
  /**
23
19
  * Headless component for product price display
24
20
  *
25
21
  * @component
26
22
  */
27
- const Price = (props) => {
28
- const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
23
+ export const Price = (props) => {
24
+ const variantService = useService(SelectedVariantServiceDefinition);
29
25
  const price = variantService.currentPrice.get();
30
26
  const compareAtPrice = variantService.currentCompareAtPrice.get();
31
27
  const currency = variantService.currency.get();
@@ -35,18 +31,16 @@ const Price = (props) => {
35
31
  currency,
36
32
  });
37
33
  };
38
- exports.Price = Price;
39
34
  /**
40
35
  * Headless component for product SKU display
41
36
  *
42
37
  * @component
43
38
  */
44
- const SKU = (props) => {
45
- const selectedVariantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
39
+ export const SKU = (props) => {
40
+ const selectedVariantService = useService(SelectedVariantServiceDefinition);
46
41
  const selectedVariant = selectedVariantService.currentVariant?.get();
47
42
  const sku = selectedVariant?.sku || null;
48
43
  return props.children({
49
44
  sku,
50
45
  });
51
46
  };
52
- exports.SKU = SKU;
@@ -1,6 +1,5 @@
1
- import React from 'react';
2
- import { type SharingPlatform } from '../services/social-sharing-service';
3
- export type { SharingPlatform };
1
+ import React from "react";
2
+ import { type SharingPlatform } from "../services/social-sharing-service.js";
4
3
  /**
5
4
  * Props for Root headless component
6
5
  */