@wix/headless-stores 0.0.10 → 0.0.12

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 (133) hide show
  1. package/cjs/dist/enums/index.d.ts +2 -0
  2. package/cjs/dist/enums/index.js +18 -0
  3. package/cjs/dist/enums/social-platform-enums.d.ts +25 -0
  4. package/cjs/dist/enums/social-platform-enums.js +30 -0
  5. package/cjs/dist/enums/sort-enums.d.ts +17 -0
  6. package/cjs/dist/enums/sort-enums.js +21 -0
  7. package/cjs/dist/react/BuyNow.d.ts +2 -4
  8. package/cjs/dist/react/Category.d.ts +9 -11
  9. package/cjs/dist/react/Category.js +8 -23
  10. package/cjs/dist/react/Collection.d.ts +13 -3
  11. package/cjs/dist/react/Collection.js +30 -19
  12. package/cjs/dist/react/FilteredCollection.d.ts +46 -15
  13. package/cjs/dist/react/FilteredCollection.js +45 -12
  14. package/cjs/dist/react/PayNow.d.ts +2 -4
  15. package/cjs/dist/react/Product.d.ts +8 -35
  16. package/cjs/dist/react/Product.js +10 -31
  17. package/cjs/dist/react/ProductActions.d.ts +42 -0
  18. package/cjs/dist/react/ProductActions.js +83 -0
  19. package/cjs/dist/react/ProductModifiers.d.ts +16 -8
  20. package/cjs/dist/react/ProductModifiers.js +19 -10
  21. package/cjs/dist/react/ProductVariantSelector.d.ts +52 -68
  22. package/cjs/dist/react/ProductVariantSelector.js +58 -86
  23. package/cjs/dist/react/RelatedProducts.d.ts +8 -4
  24. package/cjs/dist/react/RelatedProducts.js +12 -7
  25. package/cjs/dist/react/SelectedVariant.d.ts +66 -0
  26. package/cjs/dist/react/SelectedVariant.js +52 -0
  27. package/cjs/dist/react/SocialSharing.d.ts +24 -30
  28. package/cjs/dist/react/SocialSharing.js +8 -2
  29. package/cjs/dist/react/Sort.d.ts +12 -15
  30. package/cjs/dist/react/Sort.js +11 -34
  31. package/cjs/dist/react/index.d.ts +11 -10
  32. package/cjs/dist/react/index.js +3 -2
  33. package/cjs/dist/services/buy-now-service.js +2 -2
  34. package/cjs/dist/services/catalog-options-service.d.ts +2 -2
  35. package/cjs/dist/services/catalog-options-service.js +39 -45
  36. package/cjs/dist/services/catalog-price-range-service.d.ts +2 -2
  37. package/cjs/dist/services/catalog-price-range-service.js +13 -11
  38. package/cjs/dist/services/category-service.d.ts +7 -6
  39. package/cjs/dist/services/category-service.js +15 -11
  40. package/cjs/dist/services/collection-service.d.ts +8 -8
  41. package/cjs/dist/services/collection-service.js +182 -67
  42. package/cjs/dist/services/filter-service.d.ts +1 -1
  43. package/cjs/dist/services/filter-service.js +15 -23
  44. package/cjs/dist/services/product-media-gallery-service.d.ts +3 -3
  45. package/cjs/dist/services/product-modifiers-service.d.ts +6 -8
  46. package/cjs/dist/services/product-modifiers-service.js +14 -7
  47. package/cjs/dist/services/product-service.d.ts +8 -7
  48. package/cjs/dist/services/product-service.js +36 -19
  49. package/cjs/dist/services/related-products-service.d.ts +4 -4
  50. package/cjs/dist/services/related-products-service.js +4 -4
  51. package/cjs/dist/services/selected-variant-service.d.ts +24 -16
  52. package/cjs/dist/services/selected-variant-service.js +271 -126
  53. package/cjs/dist/services/social-sharing-service.d.ts +2 -2
  54. package/cjs/dist/services/social-sharing-service.js +47 -63
  55. package/cjs/dist/services/sort-service.d.ts +3 -2
  56. package/cjs/dist/services/sort-service.js +8 -13
  57. package/dist/enums/index.d.ts +2 -0
  58. package/dist/enums/index.js +2 -0
  59. package/dist/enums/social-platform-enums.d.ts +25 -0
  60. package/dist/enums/social-platform-enums.js +27 -0
  61. package/dist/enums/sort-enums.d.ts +17 -0
  62. package/dist/enums/sort-enums.js +18 -0
  63. package/dist/react/BuyNow.d.ts +2 -4
  64. package/dist/react/Category.d.ts +9 -11
  65. package/dist/react/Category.js +10 -23
  66. package/dist/react/Collection.d.ts +13 -3
  67. package/dist/react/Collection.js +32 -21
  68. package/dist/react/FilteredCollection.d.ts +46 -15
  69. package/dist/react/FilteredCollection.js +49 -16
  70. package/dist/react/PayNow.d.ts +2 -4
  71. package/dist/react/Product.d.ts +8 -35
  72. package/dist/react/Product.js +11 -31
  73. package/dist/react/ProductActions.d.ts +42 -0
  74. package/dist/react/ProductActions.js +79 -0
  75. package/dist/react/ProductModifiers.d.ts +16 -8
  76. package/dist/react/ProductModifiers.js +22 -13
  77. package/dist/react/ProductVariantSelector.d.ts +52 -68
  78. package/dist/react/ProductVariantSelector.js +57 -84
  79. package/dist/react/RelatedProducts.d.ts +8 -4
  80. package/dist/react/RelatedProducts.js +15 -10
  81. package/dist/react/SelectedVariant.d.ts +66 -0
  82. package/dist/react/SelectedVariant.js +46 -0
  83. package/dist/react/SocialSharing.d.ts +24 -30
  84. package/dist/react/SocialSharing.js +11 -5
  85. package/dist/react/Sort.d.ts +12 -15
  86. package/dist/react/Sort.js +13 -34
  87. package/dist/react/index.d.ts +11 -10
  88. package/dist/react/index.js +11 -10
  89. package/dist/services/buy-now-service.js +2 -2
  90. package/dist/services/catalog-options-service.d.ts +2 -2
  91. package/dist/services/catalog-options-service.js +41 -47
  92. package/dist/services/catalog-price-range-service.d.ts +2 -2
  93. package/dist/services/catalog-price-range-service.js +15 -13
  94. package/dist/services/category-service.d.ts +7 -6
  95. package/dist/services/category-service.js +17 -13
  96. package/dist/services/collection-service.d.ts +8 -8
  97. package/dist/services/collection-service.js +188 -73
  98. package/dist/services/filter-service.d.ts +1 -1
  99. package/dist/services/filter-service.js +20 -28
  100. package/dist/services/product-media-gallery-service.d.ts +3 -3
  101. package/dist/services/product-modifiers-service.d.ts +6 -8
  102. package/dist/services/product-modifiers-service.js +16 -9
  103. package/dist/services/product-service.d.ts +8 -7
  104. package/dist/services/product-service.js +38 -21
  105. package/dist/services/related-products-service.d.ts +4 -4
  106. package/dist/services/related-products-service.js +6 -6
  107. package/dist/services/selected-variant-service.d.ts +24 -16
  108. package/dist/services/selected-variant-service.js +273 -127
  109. package/dist/services/social-sharing-service.d.ts +2 -2
  110. package/dist/services/social-sharing-service.js +49 -65
  111. package/dist/services/sort-service.d.ts +3 -2
  112. package/dist/services/sort-service.js +11 -16
  113. package/package.json +7 -1
  114. package/cjs/dist/react/ProductMediaGallery.d.ts +0 -128
  115. package/cjs/dist/react/ProductMediaGallery.js +0 -100
  116. package/dist/astro/BuyNowServiceContext.d.ts +0 -2
  117. package/dist/astro/BuyNowServiceContext.js +0 -6
  118. package/dist/astro/ManagerProviderContext.d.ts +0 -2
  119. package/dist/astro/ManagerProviderContext.js +0 -7
  120. package/dist/astro/withBuyButtonService.d.ts +0 -2
  121. package/dist/astro/withBuyButtonService.js +0 -16
  122. package/dist/react/CurrentCartServiceProvider.d.ts +0 -5
  123. package/dist/react/CurrentCartServiceProvider.js +0 -12
  124. package/dist/react/ProductMediaGallery.d.ts +0 -128
  125. package/dist/react/ProductMediaGallery.js +0 -92
  126. package/dist/react/VariantSelectorServiceProvider.d.ts +0 -7
  127. package/dist/react/VariantSelectorServiceProvider.js +0 -22
  128. package/dist/react/hookim/index.d.ts +0 -5
  129. package/dist/react/hookim/index.js +0 -22
  130. package/dist/services/CurrentCartService.d.ts +0 -18
  131. package/dist/services/CurrentCartService.js +0 -9
  132. package/dist/services/VariantSelectorServices.d.ts +0 -8
  133. package/dist/services/VariantSelectorServices.js +0 -20
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Stock = exports.Price = exports.Trigger = exports.Choice = exports.Option = exports.Options = void 0;
3
+ exports.Reset = exports.Stock = exports.Choice = exports.Option = exports.Options = void 0;
4
4
  const services_manager_react_1 = require("@wix/services-manager-react");
5
5
  const selected_variant_service_1 = require("../services/selected-variant-service");
6
- const product_modifiers_service_1 = require("../services/product-modifiers-service");
6
+ const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
7
7
  /**
8
8
  * Headless component for all product options
9
+ *
10
+ * @component
9
11
  */
10
12
  const Options = (props) => {
11
13
  const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
@@ -20,12 +22,14 @@ const Options = (props) => {
20
22
  exports.Options = Options;
21
23
  /**
22
24
  * Headless component for choices within a specific product option
25
+ *
26
+ * @component
23
27
  */
24
28
  const Option = (props) => {
25
29
  const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
26
30
  const selectedChoices = variantService.selectedChoices.get();
27
31
  const { option } = props;
28
- const name = option.name || "";
32
+ const name = option.name || '';
29
33
  const choices = option.choicesSettings?.choices || [];
30
34
  const selectedValue = selectedChoices[name] || null;
31
35
  return props.children({
@@ -39,16 +43,22 @@ const Option = (props) => {
39
43
  exports.Option = Option;
40
44
  /**
41
45
  * Headless component for individual choice selection
46
+ *
47
+ * @component
42
48
  */
43
49
  const Choice = (props) => {
44
50
  const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
45
51
  const selectedChoices = variantService.selectedChoices.get();
46
52
  const { option, choice } = props;
47
- const optionName = option.name || "";
48
- const choiceValue = choice.name || "";
53
+ const optionName = option.name || '';
54
+ const choiceValue = choice.name || '';
49
55
  const isSelected = selectedChoices[optionName] === choiceValue;
50
56
  // Check if this choice is available based on current selections
51
- const isAvailable = variantService.isChoiceAvailable(optionName, choiceValue);
57
+ const isVisible = variantService.isChoiceAvailable(optionName, choiceValue);
58
+ // Check if this choice results in an in-stock variant
59
+ const isInStock = variantService.isChoiceInStock(optionName, choiceValue);
60
+ // Check if this choice is available for pre-order
61
+ const isPreOrderEnabled = variantService.isChoicePreOrderEnabled(optionName, choiceValue);
52
62
  const value = choiceValue;
53
63
  const onSelect = () => {
54
64
  const newChoices = {
@@ -61,7 +71,9 @@ const Choice = (props) => {
61
71
  value,
62
72
  description: undefined, // v3 choices don't have separate description field
63
73
  isSelected,
64
- isAvailable,
74
+ isVisible,
75
+ isInStock,
76
+ isPreOrderEnabled,
65
77
  onSelect,
66
78
  optionName,
67
79
  choiceValue,
@@ -69,98 +81,58 @@ const Choice = (props) => {
69
81
  };
70
82
  exports.Choice = Choice;
71
83
  /**
72
- * Headless component for add to cart trigger
84
+ * Headless component for product stock status
85
+ *
86
+ * @component
73
87
  */
74
- const Trigger = (props) => {
88
+ const Stock = (props) => {
75
89
  const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
76
- // Try to get modifiers service - it may not exist for all products
77
- let modifiersService = null;
78
- try {
79
- modifiersService = (0, services_manager_react_1.useService)(product_modifiers_service_1.ProductModifiersServiceDefinition);
80
- }
81
- catch {
82
- // Modifiers service not available for this product
83
- modifiersService = null;
84
- }
85
- const price = variantService.currentPrice.get();
86
90
  const inStock = variantService.isInStock.get();
87
91
  const isPreOrderEnabled = variantService.isPreOrderEnabled.get();
88
- const isLoading = variantService.isLoading.get();
89
- const error = variantService.error.get();
90
- const quantity = props.quantity || 1;
91
- // Check if all required modifiers are filled
92
- const areAllRequiredModifiersFilled = modifiersService
93
- ? modifiersService.areAllRequiredModifiersFilled()
94
- : true; // If no modifiers service, assume no required modifiers
95
- const canAddToCart = (inStock || isPreOrderEnabled) && !isLoading && areAllRequiredModifiersFilled;
96
- const onAddToCart = async () => {
97
- // Get modifiers data if available
98
- let modifiersData;
99
- if (modifiersService) {
100
- const selectedModifiers = modifiersService.selectedModifiers.get();
101
- if (Object.keys(selectedModifiers).length > 0) {
102
- modifiersData = selectedModifiers;
103
- }
104
- }
105
- await variantService.addToCart(quantity, modifiersData);
92
+ const trackInventory = variantService.trackQuantity.get();
93
+ const currentVariantId = variantService.selectedVariantId.get();
94
+ const availableQuantity = variantService.quantityAvailable.get();
95
+ const selectedQuantity = variantService.selectedQuantity.get();
96
+ // const currentVariant = variantService.currentVariant.get();
97
+ // const allVariantsAreOutOfStock = variantService.IsAllVariantsAreOutOfStock();
98
+ // Return raw availability status - UI components will handle display conversion
99
+ 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;
102
+ const incrementQuantity = () => {
103
+ variantService.incrementQuantity();
104
+ };
105
+ const decrementQuantity = () => {
106
+ variantService.decrementQuantity();
106
107
  };
107
108
  return props.children({
108
- onAddToCart,
109
- canAddToCart,
110
- isLoading,
111
- price,
112
109
  inStock,
110
+ availableQuantity,
113
111
  isPreOrderEnabled,
114
- error,
115
- });
116
- };
117
- exports.Trigger = Trigger;
118
- /**
119
- * Headless component for product price display
120
- */
121
- const Price = (props) => {
122
- const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
123
- const price = variantService.currentPrice.get();
124
- const compareAtPrice = variantService.currentCompareAtPrice.get();
125
- const currentVariant = variantService.currentVariant.get();
126
- const currency = variantService.currency.get();
127
- const isVariantPrice = !!currentVariant;
128
- return props.children({
129
- price,
130
- compareAtPrice,
131
- isVariantPrice,
132
- currency,
112
+ currentVariantId,
113
+ availabilityStatus,
114
+ trackInventory,
115
+ selectedQuantity,
116
+ incrementQuantity,
117
+ decrementQuantity,
133
118
  });
134
119
  };
135
- exports.Price = Price;
120
+ exports.Stock = Stock;
136
121
  /**
137
- * Headless component for product stock status
122
+ * Headless component for resetting variant selections
123
+ *
124
+ * @component
138
125
  */
139
- const Stock = (props) => {
126
+ const Reset = (props) => {
140
127
  const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
141
- const inStock = variantService.isInStock.get();
142
- const isPreOrderEnabled = variantService.isPreOrderEnabled.get();
143
- const currentVariantId = variantService.selectedVariantId.get();
144
- const trackInventory = false; // V3 API has different inventory structure
145
- const quantity = null; // Not directly available in v3 API
146
- // Determine status based on stock and pre-order availability
147
- let status;
148
- if (inStock) {
149
- status = "In Stock";
150
- }
151
- else if (isPreOrderEnabled) {
152
- status = "Available for Pre-Order";
153
- }
154
- else {
155
- status = "Out of Stock";
156
- }
128
+ const selectedChoices = variantService.selectedChoices.get();
129
+ const hasSelections = Object.keys(selectedChoices).length > 0;
130
+ const onReset = () => {
131
+ variantService.resetSelections();
132
+ };
157
133
  return props.children({
158
- inStock,
159
- isPreOrderEnabled,
160
- currentVariantId,
161
- status,
162
- quantity,
163
- trackInventory,
134
+ onReset,
135
+ hasSelections,
164
136
  });
165
137
  };
166
- exports.Stock = Stock;
138
+ exports.Reset = Reset;
@@ -1,5 +1,5 @@
1
- import React from "react";
2
- import { productsV3 } from "@wix/stores";
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
  */
@@ -12,7 +12,7 @@ export interface ListProps {
12
12
  */
13
13
  export interface ListRenderProps {
14
14
  /** Array of related products */
15
- products: productsV3.V3Product[];
15
+ products: V3Product[];
16
16
  /** Whether products are loading */
17
17
  isLoading: boolean;
18
18
  /** Error message if any */
@@ -24,6 +24,8 @@ export interface ListRenderProps {
24
24
  }
25
25
  /**
26
26
  * Headless component for displaying related products list
27
+ *
28
+ * @component
27
29
  */
28
30
  export declare const List: (props: ListProps) => React.ReactNode;
29
31
  /**
@@ -31,7 +33,7 @@ export declare const List: (props: ListProps) => React.ReactNode;
31
33
  */
32
34
  export interface ItemProps {
33
35
  /** Product data */
34
- product: productsV3.V3Product;
36
+ product: V3Product;
35
37
  /** Render prop function that receives item data */
36
38
  children: (props: ItemRenderProps) => React.ReactNode;
37
39
  }
@@ -56,5 +58,7 @@ export interface ItemRenderProps {
56
58
  }
57
59
  /**
58
60
  * Headless component for individual related product item
61
+ *
62
+ * @component
59
63
  */
60
64
  export declare const Item: (props: ItemProps) => React.ReactNode;
@@ -7,8 +7,11 @@ exports.Item = exports.List = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const services_manager_react_1 = require("@wix/services-manager-react");
9
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");
10
11
  /**
11
12
  * Headless component for displaying related products list
13
+ *
14
+ * @component
12
15
  */
13
16
  const List = (props) => {
14
17
  const service = (0, services_manager_react_1.useService)(related_products_service_1.RelatedProductsServiceDefinition);
@@ -23,7 +26,7 @@ const List = (props) => {
23
26
  service.error.subscribe(setError),
24
27
  service.hasRelatedProducts.subscribe(setHasProducts),
25
28
  ];
26
- return () => unsubscribes.forEach((fn) => fn());
29
+ return () => unsubscribes.forEach(fn => fn());
27
30
  }, [service]);
28
31
  return props.children({
29
32
  products,
@@ -36,24 +39,26 @@ const List = (props) => {
36
39
  exports.List = List;
37
40
  /**
38
41
  * Headless component for individual related product item
42
+ *
43
+ * @component
39
44
  */
40
45
  const Item = (props) => {
41
46
  const { product } = props;
42
- const title = product.name || "Unknown Product";
47
+ const title = product.name || 'Unknown Product';
43
48
  // Use actual v3 media structure - image is directly a string URL
44
49
  const image = product.media?.main?.image || null;
45
50
  // Create formatted price from raw amount since formattedAmount may not be available
46
51
  const rawPrice = product.actualPriceRange?.minValue?.amount;
47
- const price = rawPrice ? `$${rawPrice}` : "Price unavailable";
52
+ const price = rawPrice ? `$${rawPrice}` : 'Price unavailable';
48
53
  const availabilityStatus = product.inventory?.availabilityStatus;
49
- const available = availabilityStatus === "IN_STOCK" ||
50
- availabilityStatus === "PARTIALLY_OUT_OF_STOCK";
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;
51
56
  const href = `/store/example-2/${product.slug}`;
52
- const description = typeof product.description === "string" ? product.description : "";
57
+ const description = typeof product.description === 'string' ? product.description : '';
53
58
  const handleQuickAdd = () => {
54
59
  // This would typically add the product to cart
55
60
  // For now, we'll just log it
56
- console.log("Quick add:", product.name);
61
+ console.log('Quick add:', product.name);
57
62
  };
58
63
  return props.children({
59
64
  title,
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Props for ProductDetails headless component
3
+ */
4
+ export interface ProductDetailsProps {
5
+ /** Render prop function that receives product details data */
6
+ children: (props: ProductDetailsRenderProps) => React.ReactNode;
7
+ }
8
+ /**
9
+ * Render props for ProductDetails component
10
+ */
11
+ export interface ProductDetailsRenderProps {
12
+ /** Product SKU */
13
+ sku: string | null;
14
+ /** Product weight */
15
+ weight: string | null;
16
+ }
17
+ /**
18
+ * Headless component for selected variant details display
19
+ *
20
+ * @component
21
+ */
22
+ export declare const Details: (props: ProductDetailsProps) => import("react").ReactNode;
23
+ /**
24
+ * Props for Price headless component
25
+ */
26
+ export interface PriceProps {
27
+ /** Render prop function that receives price data */
28
+ children: (props: PriceRenderProps) => React.ReactNode;
29
+ }
30
+ /**
31
+ * Render props for Price component
32
+ */
33
+ export interface PriceRenderProps {
34
+ /** Current price (formatted) */
35
+ price: string;
36
+ /** Compare at price (formatted) - null if no compare price */
37
+ compareAtPrice: string | null;
38
+ /** Currency code */
39
+ currency: string;
40
+ }
41
+ /**
42
+ * Headless component for product price display
43
+ *
44
+ * @component
45
+ */
46
+ export declare const Price: (props: PriceProps) => import("react").ReactNode;
47
+ /**
48
+ * Props for SKU headless component
49
+ */
50
+ export interface SKUProps {
51
+ /** Render prop function that receives SKU data */
52
+ children: (props: SKURenderProps) => React.ReactNode;
53
+ }
54
+ /**
55
+ * Render props for SKU component
56
+ */
57
+ export interface SKURenderProps {
58
+ /** Product SKU */
59
+ sku: string | null;
60
+ }
61
+ /**
62
+ * Headless component for product SKU display
63
+ *
64
+ * @component
65
+ */
66
+ export declare const SKU: (props: SKUProps) => import("react").ReactNode;
@@ -0,0 +1,52 @@
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");
6
+ /**
7
+ * Headless component for selected variant details display
8
+ *
9
+ * @component
10
+ */
11
+ const Details = (props) => {
12
+ const selectedVariantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
13
+ const selectedVariant = selectedVariantService.currentVariant?.get();
14
+ let sku = selectedVariant?.sku || null;
15
+ let weight = selectedVariant?.physicalProperties?.weight?.toString() || null;
16
+ return props.children({
17
+ sku,
18
+ weight,
19
+ });
20
+ };
21
+ exports.Details = Details;
22
+ /**
23
+ * Headless component for product price display
24
+ *
25
+ * @component
26
+ */
27
+ const Price = (props) => {
28
+ const variantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
29
+ const price = variantService.currentPrice.get();
30
+ const compareAtPrice = variantService.currentCompareAtPrice.get();
31
+ const currency = variantService.currency.get();
32
+ return props.children({
33
+ price,
34
+ compareAtPrice,
35
+ currency,
36
+ });
37
+ };
38
+ exports.Price = Price;
39
+ /**
40
+ * Headless component for product SKU display
41
+ *
42
+ * @component
43
+ */
44
+ const SKU = (props) => {
45
+ const selectedVariantService = (0, services_manager_react_1.useService)(selected_variant_service_1.SelectedVariantServiceDefinition);
46
+ const selectedVariant = selectedVariantService.currentVariant?.get();
47
+ const sku = selectedVariant?.sku || null;
48
+ return props.children({
49
+ sku,
50
+ });
51
+ };
52
+ exports.SKU = SKU;
@@ -1,25 +1,13 @@
1
- import React from "react";
2
- import { SharingPlatform } from "../services/social-sharing-service";
1
+ import React from 'react';
2
+ import { type SharingPlatform } from '../services/social-sharing-service';
3
3
  export type { SharingPlatform };
4
- export type RootChildren = (props: RootRenderProps) => React.ReactNode;
5
4
  /**
6
5
  * Props for Root headless component
7
6
  */
8
7
  export interface RootProps {
9
8
  /** Render prop function that receives sharing data */
10
- children: RootChildren;
9
+ children: (props: RootRenderProps) => React.ReactNode;
11
10
  }
12
- export type ShareFacebook = (url: string, title: string, description?: string) => void;
13
- export type ShareTwitter = (url: string, text: string, hashtags?: string[]) => void;
14
- export type ShareLinkedIn = (url: string, title: string, summary?: string) => void;
15
- export type ShareWhatsApp = (url: string, text: string) => void;
16
- export type ShareEmail = (url: string, subject: string, body: string) => void;
17
- export type CopyLink = (url: string) => Promise<boolean>;
18
- export type ShareNative = (data: {
19
- title: string;
20
- text: string;
21
- url: string;
22
- }) => Promise<boolean>;
23
11
  /**
24
12
  * Render props for Root component
25
13
  */
@@ -31,26 +19,30 @@ export interface RootRenderProps {
31
19
  /** Last shared platform */
32
20
  lastShared: string | null;
33
21
  /** Share to Facebook */
34
- shareFacebook: ShareFacebook;
22
+ shareFacebook: (url: string, title: string, description?: string) => void;
35
23
  /** Share to Twitter */
36
- shareTwitter: ShareTwitter;
24
+ shareTwitter: (url: string, text: string, hashtags?: string[]) => void;
37
25
  /** Share to LinkedIn */
38
- shareLinkedIn: ShareLinkedIn;
26
+ shareLinkedIn: (url: string, title: string, summary?: string) => void;
39
27
  /** Share to WhatsApp */
40
- shareWhatsApp: ShareWhatsApp;
28
+ shareWhatsApp: (url: string, text: string) => void;
41
29
  /** Share via Email */
42
- shareEmail: ShareEmail;
30
+ shareEmail: (url: string, subject: string, body: string) => void;
43
31
  /** Copy to clipboard */
44
- copyLink: CopyLink;
32
+ copyLink: (url: string) => Promise<boolean>;
45
33
  /** Native share API */
46
- shareNative: ShareNative;
34
+ shareNative: (data: {
35
+ title: string;
36
+ text: string;
37
+ url: string;
38
+ }) => Promise<boolean>;
47
39
  }
48
40
  /**
49
41
  * Headless component for social sharing root
42
+ *
43
+ * @component
50
44
  */
51
45
  export declare const Root: (props: RootProps) => React.ReactNode;
52
- export type OnClick = () => void;
53
- export type PlatformChildren = (props: PlatformRenderProps) => React.ReactNode;
54
46
  /**
55
47
  * Props for Platform headless component
56
48
  */
@@ -58,11 +50,10 @@ export interface PlatformProps {
58
50
  /** Platform data */
59
51
  platform: SharingPlatform;
60
52
  /** Click handler */
61
- onClick: OnClick;
53
+ onClick: () => void;
62
54
  /** Render prop function that receives platform data */
63
- children: PlatformChildren;
55
+ children: (props: PlatformRenderProps) => React.ReactNode;
64
56
  }
65
- export type OnSelect = () => void;
66
57
  /**
67
58
  * Render props for Platform component
68
59
  */
@@ -70,13 +61,14 @@ export interface PlatformRenderProps {
70
61
  /** Platform data */
71
62
  platform: SharingPlatform;
72
63
  /** Platform click handler */
73
- onSelect: OnSelect;
64
+ onSelect: () => void;
74
65
  }
75
66
  /**
76
67
  * Headless component for individual social platform
68
+ *
69
+ * @component
77
70
  */
78
71
  export declare const Platform: (props: PlatformProps) => React.ReactNode;
79
- export type PlatformsChildren = (props: PlatformsRenderProps) => React.ReactNode;
80
72
  /**
81
73
  * Props for Platforms headless component
82
74
  */
@@ -90,7 +82,7 @@ export interface PlatformsProps {
90
82
  /** Hashtags for sharing */
91
83
  hashtags?: string[];
92
84
  /** Render prop function that receives platforms data */
93
- children: PlatformsChildren;
85
+ children: (props: PlatformsRenderProps) => React.ReactNode;
94
86
  }
95
87
  /**
96
88
  * Render props for Platforms component
@@ -115,5 +107,7 @@ export interface PlatformsRenderProps {
115
107
  }
116
108
  /**
117
109
  * Headless component for social sharing platforms with logic
110
+ *
111
+ * @component
118
112
  */
119
113
  export declare const Platforms: (props: PlatformsProps) => React.ReactNode;
@@ -9,6 +9,8 @@ const services_manager_react_1 = require("@wix/services-manager-react");
9
9
  const social_sharing_service_1 = require("../services/social-sharing-service");
10
10
  /**
11
11
  * Headless component for social sharing root
12
+ *
13
+ * @component
12
14
  */
13
15
  const Root = (props) => {
14
16
  const service = (0, services_manager_react_1.useService)(social_sharing_service_1.SocialSharingServiceDefinition);
@@ -21,7 +23,7 @@ const Root = (props) => {
21
23
  service.shareCount.subscribe(setShareCount),
22
24
  service.lastSharedPlatform.subscribe(setLastShared),
23
25
  ];
24
- return () => unsubscribes.forEach((fn) => fn());
26
+ return () => unsubscribes.forEach(fn => fn());
25
27
  }, [service]);
26
28
  return props.children({
27
29
  platforms,
@@ -39,6 +41,8 @@ const Root = (props) => {
39
41
  exports.Root = Root;
40
42
  /**
41
43
  * Headless component for individual social platform
44
+ *
45
+ * @component
42
46
  */
43
47
  const Platform = (props) => {
44
48
  const { platform, onClick } = props;
@@ -50,9 +54,11 @@ const Platform = (props) => {
50
54
  exports.Platform = Platform;
51
55
  /**
52
56
  * Headless component for social sharing platforms with logic
57
+ *
58
+ * @component
53
59
  */
54
60
  const Platforms = (props) => {
55
- const { url, title, description = "", hashtags = [] } = props;
61
+ const { url, title, description = '', hashtags = [] } = props;
56
62
  const service = (0, services_manager_react_1.useService)(social_sharing_service_1.SocialSharingServiceDefinition);
57
63
  const [platforms, setPlatforms] = react_1.default.useState([]);
58
64
  react_1.default.useEffect(() => {
@@ -1,17 +1,14 @@
1
- import React from "react";
2
- import { type SortBy } from "../services/sort-service";
3
- interface SortContextValue {
4
- currentSort: SortBy;
5
- setSortBy: (sortBy: SortBy) => void;
6
- }
7
- export declare function useSortContext(): SortContextValue;
8
- export interface ProviderProps {
9
- children: React.ReactNode;
10
- }
11
- export declare function Provider({ children }: ProviderProps): import("react/jsx-runtime").JSX.Element;
12
- export type SortControllerChildren = (props: SortContextValue) => React.ReactNode;
1
+ import React from 'react';
2
+ import { type SortBy } from '../services/sort-service';
13
3
  export interface ControllerProps {
14
- children: SortControllerChildren;
4
+ children: (props: {
5
+ currentSort: SortBy;
6
+ setSortBy: (sortBy: SortBy) => void;
7
+ }) => React.ReactNode;
15
8
  }
16
- export declare function Controller({ children }: ControllerProps): import("react/jsx-runtime").JSX.Element;
17
- export {};
9
+ /**
10
+ * Headless component for sorting products
11
+ *
12
+ * @component
13
+ */
14
+ export declare function Controller(props: ControllerProps): React.ReactNode;
@@ -1,41 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSortContext = useSortContext;
4
- exports.Provider = Provider;
5
3
  exports.Controller = Controller;
6
4
  const jsx_runtime_1 = require("react/jsx-runtime");
7
- const react_1 = require("react");
8
- const sort_service_1 = require("../services/sort-service");
9
5
  const services_manager_react_1 = require("@wix/services-manager-react");
10
- const SortContext = (0, react_1.createContext)(null);
11
- function useSortContext() {
12
- const context = (0, react_1.useContext)(SortContext);
13
- if (!context) {
14
- throw new Error("useSortContext must be used within a Sort.SortProvider");
15
- }
16
- return context;
17
- }
18
- function Provider({ children }) {
6
+ const sort_service_1 = require("../services/sort-service");
7
+ /**
8
+ * Headless component for sorting products
9
+ *
10
+ * @component
11
+ */
12
+ function Controller(props) {
13
+ const { children } = props;
19
14
  const sortService = (0, services_manager_react_1.useService)(sort_service_1.SortServiceDefinition);
20
- const [currentSort, setCurrentSort] = (0, react_1.useState)("");
21
- (0, react_1.useEffect)(() => {
22
- const unsubscribe = sortService.currentSort.subscribe((sort) => {
23
- setCurrentSort(sort);
24
- });
25
- // Initialize with current value
26
- setCurrentSort(sortService.currentSort.get());
27
- return unsubscribe;
28
- }, [sortService]);
29
- const setSortBy = (sortBy) => {
30
- sortService.setSortBy(sortBy);
31
- };
32
- const contextValue = {
33
- currentSort,
34
- setSortBy,
35
- };
36
- return ((0, jsx_runtime_1.jsx)(SortContext.Provider, { value: contextValue, children: children }));
37
- }
38
- function Controller({ children }) {
39
- const context = useSortContext();
40
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children(context) });
15
+ const currentSort = sortService.currentSort.get();
16
+ const setSortBy = sortService.setSortBy;
17
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({ currentSort, setSortBy }) });
41
18
  }