@wix/headless-stores 0.0.0

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 (150) hide show
  1. package/astro/actions/package.json +4 -0
  2. package/cjs/dist/astro/actions/custom-checkout.d.ts +50 -0
  3. package/cjs/dist/astro/actions/custom-checkout.js +53 -0
  4. package/cjs/dist/astro/actions/index.d.ts +1 -0
  5. package/cjs/dist/astro/actions/index.js +1 -0
  6. package/cjs/dist/data-component-tags.d.ts +8 -0
  7. package/cjs/dist/data-component-tags.js +9 -0
  8. package/cjs/dist/enums/index.d.ts +2 -0
  9. package/cjs/dist/enums/index.js +2 -0
  10. package/cjs/dist/enums/social-platform-enums.d.ts +25 -0
  11. package/cjs/dist/enums/social-platform-enums.js +27 -0
  12. package/cjs/dist/enums/sort-enums.d.ts +17 -0
  13. package/cjs/dist/enums/sort-enums.js +18 -0
  14. package/cjs/dist/react/Category.d.ts +242 -0
  15. package/cjs/dist/react/Category.js +235 -0
  16. package/cjs/dist/react/CategoryList.d.ts +107 -0
  17. package/cjs/dist/react/CategoryList.js +91 -0
  18. package/cjs/dist/react/Choice.d.ts +211 -0
  19. package/cjs/dist/react/Choice.js +213 -0
  20. package/cjs/dist/react/Option.d.ts +242 -0
  21. package/cjs/dist/react/Option.js +346 -0
  22. package/cjs/dist/react/Product.d.ts +1065 -0
  23. package/cjs/dist/react/Product.js +1157 -0
  24. package/cjs/dist/react/ProductList.d.ts +400 -0
  25. package/cjs/dist/react/ProductList.js +368 -0
  26. package/cjs/dist/react/core/CategoryList.d.ts +194 -0
  27. package/cjs/dist/react/core/CategoryList.js +180 -0
  28. package/cjs/dist/react/core/Product.d.ts +225 -0
  29. package/cjs/dist/react/core/Product.js +190 -0
  30. package/cjs/dist/react/core/ProductList.d.ts +235 -0
  31. package/cjs/dist/react/core/ProductList.js +217 -0
  32. package/cjs/dist/react/core/ProductListFilters.d.ts +138 -0
  33. package/cjs/dist/react/core/ProductListFilters.js +242 -0
  34. package/cjs/dist/react/core/ProductListPagination.d.ts +49 -0
  35. package/cjs/dist/react/core/ProductListPagination.js +41 -0
  36. package/cjs/dist/react/core/ProductListSort.d.ts +19 -0
  37. package/cjs/dist/react/core/ProductListSort.js +52 -0
  38. package/cjs/dist/react/core/ProductModifiers.d.ts +416 -0
  39. package/cjs/dist/react/core/ProductModifiers.js +413 -0
  40. package/cjs/dist/react/core/ProductVariantSelector.d.ts +313 -0
  41. package/cjs/dist/react/core/ProductVariantSelector.js +291 -0
  42. package/cjs/dist/react/core/SelectedVariant.d.ts +230 -0
  43. package/cjs/dist/react/core/SelectedVariant.js +269 -0
  44. package/cjs/dist/react/index.d.ts +6 -0
  45. package/cjs/dist/react/index.js +6 -0
  46. package/cjs/dist/react/types.d.ts +8 -0
  47. package/cjs/dist/react/types.js +9 -0
  48. package/cjs/dist/server-actions/custom-checkout-action.d.ts +49 -0
  49. package/cjs/dist/server-actions/custom-checkout-action.js +64 -0
  50. package/cjs/dist/server-actions/index.d.ts +1 -0
  51. package/cjs/dist/server-actions/index.js +1 -0
  52. package/cjs/dist/services/buy-now-service.d.ts +346 -0
  53. package/cjs/dist/services/buy-now-service.js +197 -0
  54. package/cjs/dist/services/categories-list-service.d.ts +164 -0
  55. package/cjs/dist/services/categories-list-service.js +148 -0
  56. package/cjs/dist/services/index.d.ts +5 -0
  57. package/cjs/dist/services/index.js +5 -0
  58. package/cjs/dist/services/pay-now-service.d.ts +214 -0
  59. package/cjs/dist/services/pay-now-service.js +156 -0
  60. package/cjs/dist/services/product-modifiers-service.d.ts +34 -0
  61. package/cjs/dist/services/product-modifiers-service.js +107 -0
  62. package/cjs/dist/services/product-service.d.ts +177 -0
  63. package/cjs/dist/services/product-service.js +190 -0
  64. package/cjs/dist/services/products-list-search-service.d.ts +1 -0
  65. package/cjs/dist/services/products-list-search-service.js +1 -0
  66. package/cjs/dist/services/products-list-service.d.ts +429 -0
  67. package/cjs/dist/services/products-list-service.js +893 -0
  68. package/cjs/dist/services/selected-variant-service.d.ts +66 -0
  69. package/cjs/dist/services/selected-variant-service.js +527 -0
  70. package/cjs/dist/utils/index.d.ts +1 -0
  71. package/cjs/dist/utils/index.js +30 -0
  72. package/cjs/dist/utils/url-params.d.ts +73 -0
  73. package/cjs/dist/utils/url-params.js +114 -0
  74. package/cjs/package.json +3 -0
  75. package/dist/astro/actions/custom-checkout.d.ts +50 -0
  76. package/dist/astro/actions/custom-checkout.js +53 -0
  77. package/dist/astro/actions/index.d.ts +1 -0
  78. package/dist/astro/actions/index.js +1 -0
  79. package/dist/data-component-tags.d.ts +8 -0
  80. package/dist/data-component-tags.js +9 -0
  81. package/dist/enums/index.d.ts +2 -0
  82. package/dist/enums/index.js +2 -0
  83. package/dist/enums/social-platform-enums.d.ts +25 -0
  84. package/dist/enums/social-platform-enums.js +27 -0
  85. package/dist/enums/sort-enums.d.ts +17 -0
  86. package/dist/enums/sort-enums.js +18 -0
  87. package/dist/react/Category.d.ts +242 -0
  88. package/dist/react/Category.js +235 -0
  89. package/dist/react/CategoryList.d.ts +107 -0
  90. package/dist/react/CategoryList.js +91 -0
  91. package/dist/react/Choice.d.ts +211 -0
  92. package/dist/react/Choice.js +213 -0
  93. package/dist/react/Option.d.ts +242 -0
  94. package/dist/react/Option.js +346 -0
  95. package/dist/react/Product.d.ts +1065 -0
  96. package/dist/react/Product.js +1157 -0
  97. package/dist/react/ProductList.d.ts +400 -0
  98. package/dist/react/ProductList.js +368 -0
  99. package/dist/react/core/CategoryList.d.ts +194 -0
  100. package/dist/react/core/CategoryList.js +180 -0
  101. package/dist/react/core/Product.d.ts +225 -0
  102. package/dist/react/core/Product.js +190 -0
  103. package/dist/react/core/ProductList.d.ts +235 -0
  104. package/dist/react/core/ProductList.js +217 -0
  105. package/dist/react/core/ProductListFilters.d.ts +138 -0
  106. package/dist/react/core/ProductListFilters.js +242 -0
  107. package/dist/react/core/ProductListPagination.d.ts +49 -0
  108. package/dist/react/core/ProductListPagination.js +41 -0
  109. package/dist/react/core/ProductListSort.d.ts +19 -0
  110. package/dist/react/core/ProductListSort.js +52 -0
  111. package/dist/react/core/ProductModifiers.d.ts +416 -0
  112. package/dist/react/core/ProductModifiers.js +413 -0
  113. package/dist/react/core/ProductVariantSelector.d.ts +313 -0
  114. package/dist/react/core/ProductVariantSelector.js +291 -0
  115. package/dist/react/core/SelectedVariant.d.ts +230 -0
  116. package/dist/react/core/SelectedVariant.js +269 -0
  117. package/dist/react/index.d.ts +6 -0
  118. package/dist/react/index.js +6 -0
  119. package/dist/react/types.d.ts +8 -0
  120. package/dist/react/types.js +9 -0
  121. package/dist/server-actions/custom-checkout-action.d.ts +49 -0
  122. package/dist/server-actions/custom-checkout-action.js +64 -0
  123. package/dist/server-actions/index.d.ts +1 -0
  124. package/dist/server-actions/index.js +1 -0
  125. package/dist/services/buy-now-service.d.ts +346 -0
  126. package/dist/services/buy-now-service.js +197 -0
  127. package/dist/services/categories-list-service.d.ts +164 -0
  128. package/dist/services/categories-list-service.js +148 -0
  129. package/dist/services/index.d.ts +5 -0
  130. package/dist/services/index.js +5 -0
  131. package/dist/services/pay-now-service.d.ts +214 -0
  132. package/dist/services/pay-now-service.js +156 -0
  133. package/dist/services/product-modifiers-service.d.ts +34 -0
  134. package/dist/services/product-modifiers-service.js +107 -0
  135. package/dist/services/product-service.d.ts +177 -0
  136. package/dist/services/product-service.js +190 -0
  137. package/dist/services/products-list-search-service.d.ts +0 -0
  138. package/dist/services/products-list-search-service.js +1 -0
  139. package/dist/services/products-list-service.d.ts +429 -0
  140. package/dist/services/products-list-service.js +893 -0
  141. package/dist/services/selected-variant-service.d.ts +66 -0
  142. package/dist/services/selected-variant-service.js +527 -0
  143. package/dist/utils/index.d.ts +1 -0
  144. package/dist/utils/index.js +30 -0
  145. package/dist/utils/url-params.d.ts +73 -0
  146. package/dist/utils/url-params.js +114 -0
  147. package/package.json +89 -0
  148. package/react/package.json +4 -0
  149. package/server-actions/package.json +4 -0
  150. package/services/package.json +4 -0
@@ -0,0 +1,180 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { useService, WixServices } from '@wix/services-manager-react';
4
+ import { createServicesMap } from '@wix/services-manager';
5
+ import { CategoriesListService, CategoriesListServiceDefinition, } from '../../services/categories-list-service.js';
6
+ /**
7
+ * Root component that provides the CategoryList service context to its children.
8
+ * This component sets up the necessary services for managing categories list state.
9
+ * Optionally connects to ProductList filtering when connectToProductFilter is enabled.
10
+ *
11
+ * @order 1
12
+ * @component
13
+ * @example
14
+ * ```tsx
15
+ * import { CategoryListCore } from '@wix/stores/components';
16
+ *
17
+ * function CategoriesPage() {
18
+ * return (
19
+ * <CategoryList.Root
20
+ * categoriesListConfig={{ categories: myCategories }}
21
+ * connectToProductFilter={true}
22
+ * >
23
+ * <CategoryList.ItemContent>
24
+ * {({ category }) => (
25
+ * <div key={category._id}>
26
+ * <h2>{category.name}</h2>
27
+ * </div>
28
+ * )}
29
+ * </CategoryList.ItemContent>
30
+ * </CategoryList.Root>
31
+ * );
32
+ * }
33
+ * ```
34
+ */
35
+ export function Root(props) {
36
+ const { categoriesListConfig, children } = props;
37
+ return (_jsx(WixServices, { servicesMap: createServicesMap().addService(CategoriesListServiceDefinition, CategoriesListService, categoriesListConfig), children: children }));
38
+ }
39
+ Root.displayName = 'CategoryList.Root';
40
+ /**
41
+ * Component that renders content when the categories list is empty.
42
+ * Only displays its children when there are no categories, no loading state, and no errors.
43
+ *
44
+ * @component
45
+ * @example
46
+ * ```tsx
47
+ * import { CategoryListCore } from '@wix/stores/components';
48
+ *
49
+ * function EmptyCategoriesMessage() {
50
+ * return (
51
+ * <CategoryList.EmptyState>
52
+ * {() => (
53
+ * <div className="empty-state">
54
+ * <h3>No categories found</h3>
55
+ * <p>Categories will appear here once they are created</p>
56
+ * </div>
57
+ * )}
58
+ * </CategoryList.EmptyState>
59
+ * );
60
+ * }
61
+ * ```
62
+ */
63
+ export function EmptyState(props) {
64
+ const { isLoading, error, categories } = useService(CategoriesListServiceDefinition);
65
+ const isLoadingValue = isLoading.get();
66
+ const errorValue = error.get();
67
+ const categoriesValue = categories.get();
68
+ if (!isLoadingValue && !errorValue && categoriesValue.length === 0) {
69
+ return typeof props.children === 'function'
70
+ ? props.children({})
71
+ : props.children;
72
+ }
73
+ return null;
74
+ }
75
+ /**
76
+ * Component that renders content during loading state.
77
+ * Only displays its children when the categories list is currently loading.
78
+ *
79
+ * @component
80
+ * @example
81
+ * ```tsx
82
+ * import { CategoryListCore } from '@wix/stores/components';
83
+ *
84
+ * function CategoriesLoading() {
85
+ * return (
86
+ * <CategoryList.Loading>
87
+ * {() => (
88
+ * <div className="loading-spinner">
89
+ * <div>Loading categories...</div>
90
+ * <div className="spinner"></div>
91
+ * </div>
92
+ * )}
93
+ * </CategoryList.Loading>
94
+ * );
95
+ * }
96
+ * ```
97
+ */
98
+ export function Loading(props) {
99
+ const { isLoading } = useService(CategoriesListServiceDefinition);
100
+ const isLoadingValue = isLoading.get();
101
+ if (isLoadingValue) {
102
+ return typeof props.children === 'function'
103
+ ? props.children({})
104
+ : props.children;
105
+ }
106
+ return null;
107
+ }
108
+ /**
109
+ * Component that renders content when there's an error loading categories.
110
+ * Only displays its children when an error has occurred.
111
+ *
112
+ * @component
113
+ * @example
114
+ * ```tsx
115
+ * import { CategoryListCore } from '@wix/stores/components';
116
+ *
117
+ * function CategoriesError() {
118
+ * return (
119
+ * <CategoryList.Error>
120
+ * {({ error }) => (
121
+ * <div className="error-state">
122
+ * <h3>Error loading categories</h3>
123
+ * <p>{error}</p>
124
+ * <button onClick={() => window.location.reload()}>
125
+ * Try Again
126
+ * </button>
127
+ * </div>
128
+ * )}
129
+ * </CategoryList.Error>
130
+ * );
131
+ * }
132
+ * ```
133
+ */
134
+ export function Error(props) {
135
+ const { error } = useService(CategoriesListServiceDefinition);
136
+ const errorValue = error.get();
137
+ if (errorValue) {
138
+ return typeof props.children === 'function'
139
+ ? props.children({ error: errorValue })
140
+ : props.children;
141
+ }
142
+ return null;
143
+ }
144
+ /**
145
+ * Component that renders content for each category in the list.
146
+ * Maps over all categories and provides each category through a service context.
147
+ * Only renders when categories are successfully loaded (not loading, no error, and has categories).
148
+ *
149
+ * @component
150
+ * @example
151
+ * ```tsx
152
+ * import { CategoryListCore } from '@wix/stores/components';
153
+ *
154
+ * function CategoriesGrid() {
155
+ * return (
156
+ * <CategoryList.ItemContent>
157
+ * {({ category }) => (
158
+ * <div className="category-card">
159
+ * <h3>{category.name}</h3>
160
+ * <p>{category.description}</p>
161
+ * <a href={`/categories/${category.slug}`}>View Category</a>
162
+ * </div>
163
+ * )}
164
+ * </CategoryList.ItemContent>
165
+ * );
166
+ * }
167
+ * ```
168
+ */
169
+ export function ItemContent(props) {
170
+ const { categories, isLoading, error } = useService(CategoriesListServiceDefinition);
171
+ const categoriesValue = categories.get();
172
+ if (isLoading.get() || error.get() || categoriesValue.length === 0) {
173
+ return null;
174
+ }
175
+ return categoriesValue.map((category) => (_jsx(React.Fragment, { children: typeof props.children === 'function'
176
+ ? props.children({
177
+ category,
178
+ })
179
+ : props.children }, category._id)));
180
+ }
@@ -0,0 +1,225 @@
1
+ import { ProductServiceConfig } from '../../services/product-service.js';
2
+ import type { V3Product, ProductMedia } from '@wix/auto_sdk_stores_products-v-3';
3
+ export interface RootProps {
4
+ children: React.ReactNode;
5
+ productServiceConfig: ProductServiceConfig;
6
+ }
7
+ /**
8
+ * Root component that provides the Product service context to its children.
9
+ * This component sets up the necessary services for rendering and managing a single product's data.
10
+ *
11
+ * @order 1
12
+ * @component
13
+ * @example
14
+ * ```tsx
15
+ * import { Product } from '@wix/stores/components';
16
+ *
17
+ * function ProductPage() {
18
+ * return (
19
+ * <Product.Root productServiceConfig={{ product: myProduct }}>
20
+ * <div>
21
+ * <Product.Name>
22
+ * {({ name }) => (
23
+ * <h1
24
+ * className="text-4xl font-bold text-content-primary mb-4"
25
+ * data-testid="product-name"
26
+ * >
27
+ * {name}
28
+ * </h1>
29
+ * )}
30
+ * </Product.Name>
31
+ * </div>
32
+ * </Product.Root>
33
+ * );
34
+ * }
35
+ * ```
36
+ */
37
+ export declare function Root(props: RootProps): React.ReactNode;
38
+ /**
39
+ * Props for ProductName headless component
40
+ */
41
+ export interface ProductNameProps {
42
+ /** Render prop function that receives product name data */
43
+ children: (props: ProductNameRenderProps) => React.ReactNode;
44
+ }
45
+ /**
46
+ * Render props for ProductName component
47
+ */
48
+ export interface ProductNameRenderProps {
49
+ /** Product name */
50
+ name: string;
51
+ }
52
+ /**
53
+ * Headless component for product name display
54
+ *
55
+ * @component
56
+ * @example
57
+ * ```tsx
58
+ * import { Product } from '@wix/stores/components';
59
+ *
60
+ * function ProductHeader() {
61
+ * return (
62
+ * <Product.Name>
63
+ * {({ name }) => (
64
+ * <h1>{name}</h1>
65
+ * )}
66
+ * </Product.Name>
67
+ * );
68
+ * }
69
+ * ```
70
+ */
71
+ export declare function Name(props: ProductNameProps): import("react").ReactNode;
72
+ /**
73
+ * Props for ProductDescription headless component
74
+ */
75
+ export interface ProductDescriptionProps {
76
+ /** Render prop function that receives product description data */
77
+ children: (props: ProductDescriptionRenderProps) => React.ReactNode;
78
+ }
79
+ /**
80
+ * Render props for ProductDescription component
81
+ */
82
+ export interface ProductDescriptionRenderProps {
83
+ /** Product description using the RICOS (Rich Content Object) format. See https://dev.wix.com/docs/ricos/api-reference/ricos-document */
84
+ description: NonNullable<V3Product['description']>;
85
+ /** Product description with plain html */
86
+ plainDescription: NonNullable<V3Product['plainDescription']>;
87
+ }
88
+ /**
89
+ * Render props for ProductDescription component
90
+ */
91
+ export interface ProductDescriptionRenderProps {
92
+ /** Product description using the RICOS (Rich Content Object) format. See https://dev.wix.com/docs/ricos/api-reference/ricos-document */
93
+ description: NonNullable<V3Product['description']>;
94
+ /** Product description with plain html */
95
+ plainDescription: NonNullable<V3Product['plainDescription']>;
96
+ }
97
+ /**
98
+ * Headless component for product description display
99
+ *
100
+ * @component
101
+ * @example
102
+ * ```tsx
103
+ * import { Product } from '@wix/stores/components';
104
+ *
105
+ * function ProductDescription() {
106
+ * return (
107
+ * <Product.Description>
108
+ * {({ plainDescription, description }) => (
109
+ * <div>
110
+ * {plainDescription && (
111
+ * <div
112
+ * dangerouslySetInnerHTML={{
113
+ * __html: plainDescription,
114
+ * }}
115
+ * />
116
+ * )}
117
+ * {description && (
118
+ * <div>Rich content description available</div>
119
+ * )}
120
+ * </div>
121
+ * )}
122
+ * </Product.Description>
123
+ * );
124
+ * }
125
+ * ```
126
+ */
127
+ export declare function Description(props: ProductDescriptionProps): import("react").ReactNode;
128
+ export interface ProductMediaProps {
129
+ children: (props: ProductMediaRenderProps) => React.ReactNode;
130
+ }
131
+ export interface ProductMediaRenderProps {
132
+ mediaItems: ProductMedia[];
133
+ mainMedia?: ProductMedia;
134
+ }
135
+ export declare function Media(props: ProductMediaProps): import("react").ReactNode;
136
+ export interface ProductProps {
137
+ children: (props: ProductRenderProps) => React.ReactNode;
138
+ }
139
+ export interface ProductRenderProps {
140
+ product: V3Product;
141
+ }
142
+ export declare function Content(props: ProductProps): import("react").ReactNode;
143
+ export interface LoadingProps {
144
+ children: (props: LoadingRenderProps) => React.ReactNode;
145
+ }
146
+ export interface LoadingRenderProps {
147
+ isLoading: boolean;
148
+ }
149
+ export declare function Loading(props: LoadingProps): import("react").ReactNode;
150
+ /**
151
+ * Props for ProductSlug headless component
152
+ */
153
+ export interface ProductSlugProps {
154
+ /** Render prop function that receives product slug data */
155
+ children: (props: ProductSlugRenderProps) => React.ReactNode;
156
+ }
157
+ /**
158
+ * Render props for ProductSlug component
159
+ */
160
+ export interface ProductSlugRenderProps {
161
+ /** Product slug */
162
+ slug: string;
163
+ }
164
+ /**
165
+ * Headless component for product slug display
166
+ *
167
+ * @component
168
+ * @example
169
+ * ```tsx
170
+ * import { Product } from '@wix/stores/components';
171
+ *
172
+ * function ProductSlugDisplay() {
173
+ * return (
174
+ * <Product.Slug>
175
+ * {({ slug }) => (
176
+ * <a href={`/product/${slug}`}>
177
+ * View Product
178
+ * </a>
179
+ * )}
180
+ * </Product.Slug>
181
+ * );
182
+ * }
183
+ * ```
184
+ */
185
+ export declare function Slug(props: ProductSlugProps): import("react").ReactNode;
186
+ /**
187
+ * Props for ProductRibbon headless component
188
+ */
189
+ export interface ProductRibbonProps {
190
+ /** Render prop function that receives product ribbon data */
191
+ children: (props: ProductRibbonRenderProps) => React.ReactNode;
192
+ }
193
+ /**
194
+ * Render props for ProductRibbon component
195
+ */
196
+ export interface ProductRibbonRenderProps {
197
+ /** Product ribbon text */
198
+ ribbon: string | null;
199
+ /** Whether the product has a ribbon */
200
+ hasRibbon: boolean;
201
+ }
202
+ /**
203
+ * Headless component for product ribbon display
204
+ *
205
+ * @component
206
+ * @example
207
+ * ```tsx
208
+ * import { Product } from '@wix/stores/components';
209
+ *
210
+ * function ProductRibbonDisplay() {
211
+ * return (
212
+ * <Product.Ribbon>
213
+ * {({ ribbon, hasRibbon }) => (
214
+ * hasRibbon ? (
215
+ * <span className="ribbon-badge">
216
+ * {ribbon}
217
+ * </span>
218
+ * ) : null
219
+ * )}
220
+ * </Product.Ribbon>
221
+ * );
222
+ * }
223
+ * ```
224
+ */
225
+ export declare function Ribbon(props: ProductRibbonProps): import("react").ReactNode;
@@ -0,0 +1,190 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useService, WixServices } from '@wix/services-manager-react';
3
+ import { ProductServiceDefinition, ProductService, } from '../../services/product-service.js';
4
+ import { createServicesMap } from '@wix/services-manager';
5
+ /**
6
+ * Root component that provides the Product service context to its children.
7
+ * This component sets up the necessary services for rendering and managing a single product's data.
8
+ *
9
+ * @order 1
10
+ * @component
11
+ * @example
12
+ * ```tsx
13
+ * import { Product } from '@wix/stores/components';
14
+ *
15
+ * function ProductPage() {
16
+ * return (
17
+ * <Product.Root productServiceConfig={{ product: myProduct }}>
18
+ * <div>
19
+ * <Product.Name>
20
+ * {({ name }) => (
21
+ * <h1
22
+ * className="text-4xl font-bold text-content-primary mb-4"
23
+ * data-testid="product-name"
24
+ * >
25
+ * {name}
26
+ * </h1>
27
+ * )}
28
+ * </Product.Name>
29
+ * </div>
30
+ * </Product.Root>
31
+ * );
32
+ * }
33
+ * ```
34
+ */
35
+ export function Root(props) {
36
+ return (_jsx(WixServices, { servicesMap: createServicesMap().addService(ProductServiceDefinition, ProductService, props.productServiceConfig), children: props.children }));
37
+ }
38
+ /**
39
+ * Headless component for product name display
40
+ *
41
+ * @component
42
+ * @example
43
+ * ```tsx
44
+ * import { Product } from '@wix/stores/components';
45
+ *
46
+ * function ProductHeader() {
47
+ * return (
48
+ * <Product.Name>
49
+ * {({ name }) => (
50
+ * <h1>{name}</h1>
51
+ * )}
52
+ * </Product.Name>
53
+ * );
54
+ * }
55
+ * ```
56
+ */
57
+ export function Name(props) {
58
+ const service = useService(ProductServiceDefinition);
59
+ const product = service.product.get();
60
+ const name = product.name;
61
+ return props.children({
62
+ name,
63
+ });
64
+ }
65
+ /**
66
+ * Headless component for product description display
67
+ *
68
+ * @component
69
+ * @example
70
+ * ```tsx
71
+ * import { Product } from '@wix/stores/components';
72
+ *
73
+ * function ProductDescription() {
74
+ * return (
75
+ * <Product.Description>
76
+ * {({ plainDescription, description }) => (
77
+ * <div>
78
+ * {plainDescription && (
79
+ * <div
80
+ * dangerouslySetInnerHTML={{
81
+ * __html: plainDescription,
82
+ * }}
83
+ * />
84
+ * )}
85
+ * {description && (
86
+ * <div>Rich content description available</div>
87
+ * )}
88
+ * </div>
89
+ * )}
90
+ * </Product.Description>
91
+ * );
92
+ * }
93
+ * ```
94
+ */
95
+ export function Description(props) {
96
+ const service = useService(ProductServiceDefinition);
97
+ const product = service.product.get();
98
+ const descriptionRichContent = product.description;
99
+ const plainDescription = product.plainDescription;
100
+ return props.children({
101
+ description: descriptionRichContent,
102
+ plainDescription: plainDescription,
103
+ });
104
+ }
105
+ export function Media(props) {
106
+ const service = useService(ProductServiceDefinition);
107
+ const product = service.product.get();
108
+ const mainMedia = product.media?.main;
109
+ const mediaItems = product.media?.itemsInfo?.items ?? [];
110
+ return props.children({
111
+ mediaItems,
112
+ mainMedia,
113
+ });
114
+ }
115
+ export function Content(props) {
116
+ const service = useService(ProductServiceDefinition);
117
+ const product = service.product.get();
118
+ return props.children({
119
+ product,
120
+ });
121
+ }
122
+ export function Loading(props) {
123
+ const service = useService(ProductServiceDefinition);
124
+ const isLoading = service.isLoading.get();
125
+ return props.children({
126
+ isLoading,
127
+ });
128
+ }
129
+ /**
130
+ * Headless component for product slug display
131
+ *
132
+ * @component
133
+ * @example
134
+ * ```tsx
135
+ * import { Product } from '@wix/stores/components';
136
+ *
137
+ * function ProductSlugDisplay() {
138
+ * return (
139
+ * <Product.Slug>
140
+ * {({ slug }) => (
141
+ * <a href={`/product/${slug}`}>
142
+ * View Product
143
+ * </a>
144
+ * )}
145
+ * </Product.Slug>
146
+ * );
147
+ * }
148
+ * ```
149
+ */
150
+ export function Slug(props) {
151
+ const service = useService(ProductServiceDefinition);
152
+ const product = service.product.get();
153
+ const slug = product.slug;
154
+ return props.children({
155
+ slug,
156
+ });
157
+ }
158
+ /**
159
+ * Headless component for product ribbon display
160
+ *
161
+ * @component
162
+ * @example
163
+ * ```tsx
164
+ * import { Product } from '@wix/stores/components';
165
+ *
166
+ * function ProductRibbonDisplay() {
167
+ * return (
168
+ * <Product.Ribbon>
169
+ * {({ ribbon, hasRibbon }) => (
170
+ * hasRibbon ? (
171
+ * <span className="ribbon-badge">
172
+ * {ribbon}
173
+ * </span>
174
+ * ) : null
175
+ * )}
176
+ * </Product.Ribbon>
177
+ * );
178
+ * }
179
+ * ```
180
+ */
181
+ export function Ribbon(props) {
182
+ const service = useService(ProductServiceDefinition);
183
+ const product = service.product.get();
184
+ const ribbon = product.ribbon?.name || null;
185
+ const hasRibbon = !!ribbon;
186
+ return props.children({
187
+ ribbon,
188
+ hasRibbon,
189
+ });
190
+ }