@wix/headless-stores 0.0.29 → 0.0.31
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.
- package/cjs/dist/react/Category.d.ts +30 -0
- package/cjs/dist/react/Category.js +30 -0
- package/cjs/dist/react/Collection.d.ts +145 -0
- package/cjs/dist/react/Collection.js +145 -0
- package/cjs/dist/react/FilteredCollection.d.ts +134 -0
- package/cjs/dist/react/FilteredCollection.js +134 -0
- package/cjs/dist/react/Product.d.ts +43 -18
- package/cjs/dist/react/Product.js +43 -18
- package/cjs/dist/react/ProductActions.d.ts +30 -0
- package/cjs/dist/react/ProductActions.js +30 -0
- package/cjs/dist/react/ProductModifiers.d.ts +172 -0
- package/cjs/dist/react/ProductModifiers.js +172 -0
- package/cjs/dist/react/ProductVariantSelector.d.ts +118 -0
- package/cjs/dist/react/ProductVariantSelector.js +118 -0
- package/cjs/dist/react/ProductsList.d.ts +107 -16
- package/cjs/dist/react/ProductsList.js +101 -16
- package/cjs/dist/react/RelatedProducts.d.ts +55 -0
- package/cjs/dist/react/RelatedProducts.js +55 -0
- package/cjs/dist/react/SelectedVariant.d.ts +59 -0
- package/cjs/dist/react/SelectedVariant.js +59 -0
- package/cjs/dist/react/SocialSharing.d.ts +82 -0
- package/cjs/dist/react/SocialSharing.js +82 -0
- package/cjs/dist/react/Sort.d.ts +22 -0
- package/cjs/dist/react/Sort.js +22 -0
- package/cjs/dist/services/category-service.d.ts +87 -0
- package/cjs/dist/services/category-service.js +87 -0
- package/cjs/dist/services/collection-service.d.ts +89 -0
- package/cjs/dist/services/collection-service.js +89 -0
- package/cjs/dist/services/product-service.d.ts +76 -0
- package/cjs/dist/services/product-service.js +76 -0
- package/cjs/dist/services/products-list-service.d.ts +93 -0
- package/cjs/dist/services/products-list-service.js +93 -0
- package/cjs/dist/services/related-products-service.d.ts +75 -0
- package/cjs/dist/services/related-products-service.js +75 -0
- package/dist/react/Category.d.ts +30 -0
- package/dist/react/Category.js +30 -0
- package/dist/react/Collection.d.ts +145 -0
- package/dist/react/Collection.js +145 -0
- package/dist/react/FilteredCollection.d.ts +134 -0
- package/dist/react/FilteredCollection.js +134 -0
- package/dist/react/Product.d.ts +43 -18
- package/dist/react/Product.js +43 -18
- package/dist/react/ProductActions.d.ts +30 -0
- package/dist/react/ProductActions.js +30 -0
- package/dist/react/ProductModifiers.d.ts +172 -0
- package/dist/react/ProductModifiers.js +172 -0
- package/dist/react/ProductVariantSelector.d.ts +118 -0
- package/dist/react/ProductVariantSelector.js +118 -0
- package/dist/react/ProductsList.d.ts +107 -16
- package/dist/react/ProductsList.js +101 -16
- package/dist/react/RelatedProducts.d.ts +55 -0
- package/dist/react/RelatedProducts.js +55 -0
- package/dist/react/SelectedVariant.d.ts +59 -0
- package/dist/react/SelectedVariant.js +59 -0
- package/dist/react/SocialSharing.d.ts +82 -0
- package/dist/react/SocialSharing.js +82 -0
- package/dist/react/Sort.d.ts +22 -0
- package/dist/react/Sort.js +22 -0
- package/dist/services/category-service.d.ts +87 -0
- package/dist/services/category-service.js +87 -0
- package/dist/services/collection-service.d.ts +89 -0
- package/dist/services/collection-service.js +89 -0
- package/dist/services/product-service.d.ts +76 -0
- package/dist/services/product-service.js +76 -0
- package/dist/services/products-list-service.d.ts +93 -0
- package/dist/services/products-list-service.js +93 -0
- package/dist/services/related-products-service.d.ts +75 -0
- package/dist/services/related-products-service.js +75 -0
- package/package.json +1 -1
|
@@ -11,6 +11,26 @@ export interface FiltersLoadingProps {
|
|
|
11
11
|
* Headless component for displaying a loading state for filters
|
|
12
12
|
*
|
|
13
13
|
* @component
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { FilteredCollection } from '@wix/stores/components';
|
|
17
|
+
*
|
|
18
|
+
* function FiltersLoadingIndicator() {
|
|
19
|
+
* return (
|
|
20
|
+
* <FilteredCollection.FiltersLoading>
|
|
21
|
+
* {({ isFullyLoaded }) => (
|
|
22
|
+
* <div>
|
|
23
|
+
* {!isFullyLoaded && (
|
|
24
|
+
* <div className="loading-pulse">
|
|
25
|
+
* Loading filters...
|
|
26
|
+
* </div>
|
|
27
|
+
* )}
|
|
28
|
+
* </div>
|
|
29
|
+
* )}
|
|
30
|
+
* </FilteredCollection.FiltersLoading>
|
|
31
|
+
* );
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
14
34
|
*/
|
|
15
35
|
export declare const FiltersLoading: React.FC<FiltersLoadingProps>;
|
|
16
36
|
export interface FilteredGridProps {
|
|
@@ -27,6 +47,35 @@ export interface FilteredGridProps {
|
|
|
27
47
|
* Headless component for displaying a grid of filtered products
|
|
28
48
|
*
|
|
29
49
|
* @component
|
|
50
|
+
* @example
|
|
51
|
+
* ```tsx
|
|
52
|
+
* import { FilteredCollection } from '@wix/stores/components';
|
|
53
|
+
*
|
|
54
|
+
* function FilteredProductsGrid() {
|
|
55
|
+
* return (
|
|
56
|
+
* <FilteredCollection.Grid>
|
|
57
|
+
* {({ products, isLoading, error, isEmpty, totalProducts, hasMoreProducts }) => (
|
|
58
|
+
* <div>
|
|
59
|
+
* {isLoading && <div>Loading filtered products...</div>}
|
|
60
|
+
* {error && <div>Error: {error}</div>}
|
|
61
|
+
* {isEmpty && <div>No products match your filters</div>}
|
|
62
|
+
* {products.length > 0 && (
|
|
63
|
+
* <div>
|
|
64
|
+
* <p>Showing {products.length} of {totalProducts} products</p>
|
|
65
|
+
* <div className="filtered-grid">
|
|
66
|
+
* {products.map(product => (
|
|
67
|
+
* <div key={product.id}>{product.name}</div>
|
|
68
|
+
* ))}
|
|
69
|
+
* </div>
|
|
70
|
+
* {hasMoreProducts && <button>Load More</button>}
|
|
71
|
+
* </div>
|
|
72
|
+
* )}
|
|
73
|
+
* </div>
|
|
74
|
+
* )}
|
|
75
|
+
* </FilteredCollection.Grid>
|
|
76
|
+
* );
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
30
79
|
*/
|
|
31
80
|
export declare const Grid: React.FC<FilteredGridProps>;
|
|
32
81
|
export interface FilteredItemProps {
|
|
@@ -46,6 +95,30 @@ export interface FilteredItemProps {
|
|
|
46
95
|
* Headless component for displaying a filtered product item
|
|
47
96
|
*
|
|
48
97
|
* @component
|
|
98
|
+
* @example
|
|
99
|
+
* ```tsx
|
|
100
|
+
* import { FilteredCollection } from '@wix/stores/components';
|
|
101
|
+
*
|
|
102
|
+
* function FilteredProductItem({ product }) {
|
|
103
|
+
* return (
|
|
104
|
+
* <FilteredCollection.Item product={product}>
|
|
105
|
+
* {({ title, image, price, compareAtPrice, available, slug, description }) => (
|
|
106
|
+
* <div className={`product-item ${!available ? 'unavailable' : ''}`}>
|
|
107
|
+
* {image && <img src={image} alt={title} />}
|
|
108
|
+
* <h3>{title}</h3>
|
|
109
|
+
* {description && <p>{description}</p>}
|
|
110
|
+
* <div className="price">
|
|
111
|
+
* <span className="current">{price}</span>
|
|
112
|
+
* {compareAtPrice && <span className="compare"><s>{compareAtPrice}</s></span>}
|
|
113
|
+
* </div>
|
|
114
|
+
* {!available && <div className="out-of-stock">Out of Stock</div>}
|
|
115
|
+
* <a href={`/product/${slug}`}>View Details</a>
|
|
116
|
+
* </div>
|
|
117
|
+
* )}
|
|
118
|
+
* </FilteredCollection.Item>
|
|
119
|
+
* );
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
49
122
|
*/
|
|
50
123
|
export declare const Item: React.FC<FilteredItemProps>;
|
|
51
124
|
export interface FilteredLoadMoreProps {
|
|
@@ -62,6 +135,35 @@ export interface FilteredLoadMoreProps {
|
|
|
62
135
|
* Headless component for load more filtered products functionality
|
|
63
136
|
*
|
|
64
137
|
* @component
|
|
138
|
+
* @example
|
|
139
|
+
* ```tsx
|
|
140
|
+
* import { FilteredCollection } from '@wix/stores/components';
|
|
141
|
+
*
|
|
142
|
+
* function LoadMoreProducts() {
|
|
143
|
+
* return (
|
|
144
|
+
* <FilteredCollection.LoadMore>
|
|
145
|
+
* {({ loadMore, refresh, isLoading, hasProducts, totalProducts, hasMoreProducts }) => (
|
|
146
|
+
* <div>
|
|
147
|
+
* {hasProducts && (
|
|
148
|
+
* <div>
|
|
149
|
+
* <p>Showing products ({totalProducts} total)</p>
|
|
150
|
+
* {hasMoreProducts && (
|
|
151
|
+
* <button
|
|
152
|
+
* onClick={loadMore}
|
|
153
|
+
* disabled={isLoading}
|
|
154
|
+
* >
|
|
155
|
+
* {isLoading ? 'Loading...' : 'Load More'}
|
|
156
|
+
* </button>
|
|
157
|
+
* )}
|
|
158
|
+
* <button onClick={refresh}>Refresh</button>
|
|
159
|
+
* </div>
|
|
160
|
+
* )}
|
|
161
|
+
* </div>
|
|
162
|
+
* )}
|
|
163
|
+
* </FilteredCollection.LoadMore>
|
|
164
|
+
* );
|
|
165
|
+
* }
|
|
166
|
+
* ```
|
|
65
167
|
*/
|
|
66
168
|
export declare const LoadMore: React.FC<FilteredLoadMoreProps>;
|
|
67
169
|
export interface FilteredFiltersProps {
|
|
@@ -78,5 +180,37 @@ export interface FilteredFiltersProps {
|
|
|
78
180
|
* Headless component for product filters with available options
|
|
79
181
|
*
|
|
80
182
|
* @component
|
|
183
|
+
* @example
|
|
184
|
+
* ```tsx
|
|
185
|
+
* import { FilteredCollection } from '@wix/stores/components';
|
|
186
|
+
*
|
|
187
|
+
* function ProductFilters() {
|
|
188
|
+
* return (
|
|
189
|
+
* <FilteredCollection.Filters>
|
|
190
|
+
* {({ applyFilters, clearFilters, currentFilters, availableOptions, isFiltered }) => (
|
|
191
|
+
* <div className="filters">
|
|
192
|
+
* <h3>Filters</h3>
|
|
193
|
+
* <div className="price-filter">
|
|
194
|
+
* <label>Price Range</label>
|
|
195
|
+
* <input
|
|
196
|
+
* type="range"
|
|
197
|
+
* min={availableOptions.priceRange.min}
|
|
198
|
+
* max={availableOptions.priceRange.max}
|
|
199
|
+
* value={currentFilters.priceRange.min}
|
|
200
|
+
* onChange={(e) => applyFilters({
|
|
201
|
+
* ...currentFilters,
|
|
202
|
+
* priceRange: { ...currentFilters.priceRange, min: Number(e.target.value) }
|
|
203
|
+
* })}
|
|
204
|
+
* />
|
|
205
|
+
* </div>
|
|
206
|
+
* {isFiltered && (
|
|
207
|
+
* <button onClick={clearFilters}>Clear All Filters</button>
|
|
208
|
+
* )}
|
|
209
|
+
* </div>
|
|
210
|
+
* )}
|
|
211
|
+
* </FilteredCollection.Filters>
|
|
212
|
+
* );
|
|
213
|
+
* }
|
|
214
|
+
* ```
|
|
81
215
|
*/
|
|
82
216
|
export declare const Filters: React.FC<FilteredFiltersProps>;
|
|
@@ -7,6 +7,26 @@ import { InventoryAvailabilityStatus, } from "@wix/auto_sdk_stores_products-v-3"
|
|
|
7
7
|
* Headless component for displaying a loading state for filters
|
|
8
8
|
*
|
|
9
9
|
* @component
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { FilteredCollection } from '@wix/stores/components';
|
|
13
|
+
*
|
|
14
|
+
* function FiltersLoadingIndicator() {
|
|
15
|
+
* return (
|
|
16
|
+
* <FilteredCollection.FiltersLoading>
|
|
17
|
+
* {({ isFullyLoaded }) => (
|
|
18
|
+
* <div>
|
|
19
|
+
* {!isFullyLoaded && (
|
|
20
|
+
* <div className="loading-pulse">
|
|
21
|
+
* Loading filters...
|
|
22
|
+
* </div>
|
|
23
|
+
* )}
|
|
24
|
+
* </div>
|
|
25
|
+
* )}
|
|
26
|
+
* </FilteredCollection.FiltersLoading>
|
|
27
|
+
* );
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
10
30
|
*/
|
|
11
31
|
export const FiltersLoading = ({ children }) => {
|
|
12
32
|
const filter = useService(FilterServiceDefinition);
|
|
@@ -17,6 +37,35 @@ export const FiltersLoading = ({ children }) => {
|
|
|
17
37
|
* Headless component for displaying a grid of filtered products
|
|
18
38
|
*
|
|
19
39
|
* @component
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* import { FilteredCollection } from '@wix/stores/components';
|
|
43
|
+
*
|
|
44
|
+
* function FilteredProductsGrid() {
|
|
45
|
+
* return (
|
|
46
|
+
* <FilteredCollection.Grid>
|
|
47
|
+
* {({ products, isLoading, error, isEmpty, totalProducts, hasMoreProducts }) => (
|
|
48
|
+
* <div>
|
|
49
|
+
* {isLoading && <div>Loading filtered products...</div>}
|
|
50
|
+
* {error && <div>Error: {error}</div>}
|
|
51
|
+
* {isEmpty && <div>No products match your filters</div>}
|
|
52
|
+
* {products.length > 0 && (
|
|
53
|
+
* <div>
|
|
54
|
+
* <p>Showing {products.length} of {totalProducts} products</p>
|
|
55
|
+
* <div className="filtered-grid">
|
|
56
|
+
* {products.map(product => (
|
|
57
|
+
* <div key={product.id}>{product.name}</div>
|
|
58
|
+
* ))}
|
|
59
|
+
* </div>
|
|
60
|
+
* {hasMoreProducts && <button>Load More</button>}
|
|
61
|
+
* </div>
|
|
62
|
+
* )}
|
|
63
|
+
* </div>
|
|
64
|
+
* )}
|
|
65
|
+
* </FilteredCollection.Grid>
|
|
66
|
+
* );
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
20
69
|
*/
|
|
21
70
|
export const Grid = ({ children }) => {
|
|
22
71
|
const collection = useService(CollectionServiceDefinition);
|
|
@@ -39,6 +88,30 @@ export const Grid = ({ children }) => {
|
|
|
39
88
|
* Headless component for displaying a filtered product item
|
|
40
89
|
*
|
|
41
90
|
* @component
|
|
91
|
+
* @example
|
|
92
|
+
* ```tsx
|
|
93
|
+
* import { FilteredCollection } from '@wix/stores/components';
|
|
94
|
+
*
|
|
95
|
+
* function FilteredProductItem({ product }) {
|
|
96
|
+
* return (
|
|
97
|
+
* <FilteredCollection.Item product={product}>
|
|
98
|
+
* {({ title, image, price, compareAtPrice, available, slug, description }) => (
|
|
99
|
+
* <div className={`product-item ${!available ? 'unavailable' : ''}`}>
|
|
100
|
+
* {image && <img src={image} alt={title} />}
|
|
101
|
+
* <h3>{title}</h3>
|
|
102
|
+
* {description && <p>{description}</p>}
|
|
103
|
+
* <div className="price">
|
|
104
|
+
* <span className="current">{price}</span>
|
|
105
|
+
* {compareAtPrice && <span className="compare"><s>{compareAtPrice}</s></span>}
|
|
106
|
+
* </div>
|
|
107
|
+
* {!available && <div className="out-of-stock">Out of Stock</div>}
|
|
108
|
+
* <a href={`/product/${slug}`}>View Details</a>
|
|
109
|
+
* </div>
|
|
110
|
+
* )}
|
|
111
|
+
* </FilteredCollection.Item>
|
|
112
|
+
* );
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
42
115
|
*/
|
|
43
116
|
export const Item = ({ product, children }) => {
|
|
44
117
|
// Safe conversion of product data with type safety guards
|
|
@@ -77,6 +150,35 @@ export const Item = ({ product, children }) => {
|
|
|
77
150
|
* Headless component for load more filtered products functionality
|
|
78
151
|
*
|
|
79
152
|
* @component
|
|
153
|
+
* @example
|
|
154
|
+
* ```tsx
|
|
155
|
+
* import { FilteredCollection } from '@wix/stores/components';
|
|
156
|
+
*
|
|
157
|
+
* function LoadMoreProducts() {
|
|
158
|
+
* return (
|
|
159
|
+
* <FilteredCollection.LoadMore>
|
|
160
|
+
* {({ loadMore, refresh, isLoading, hasProducts, totalProducts, hasMoreProducts }) => (
|
|
161
|
+
* <div>
|
|
162
|
+
* {hasProducts && (
|
|
163
|
+
* <div>
|
|
164
|
+
* <p>Showing products ({totalProducts} total)</p>
|
|
165
|
+
* {hasMoreProducts && (
|
|
166
|
+
* <button
|
|
167
|
+
* onClick={loadMore}
|
|
168
|
+
* disabled={isLoading}
|
|
169
|
+
* >
|
|
170
|
+
* {isLoading ? 'Loading...' : 'Load More'}
|
|
171
|
+
* </button>
|
|
172
|
+
* )}
|
|
173
|
+
* <button onClick={refresh}>Refresh</button>
|
|
174
|
+
* </div>
|
|
175
|
+
* )}
|
|
176
|
+
* </div>
|
|
177
|
+
* )}
|
|
178
|
+
* </FilteredCollection.LoadMore>
|
|
179
|
+
* );
|
|
180
|
+
* }
|
|
181
|
+
* ```
|
|
80
182
|
*/
|
|
81
183
|
export const LoadMore = ({ children }) => {
|
|
82
184
|
const collection = useService(CollectionServiceDefinition);
|
|
@@ -99,6 +201,38 @@ export const LoadMore = ({ children }) => {
|
|
|
99
201
|
* Headless component for product filters with available options
|
|
100
202
|
*
|
|
101
203
|
* @component
|
|
204
|
+
* @example
|
|
205
|
+
* ```tsx
|
|
206
|
+
* import { FilteredCollection } from '@wix/stores/components';
|
|
207
|
+
*
|
|
208
|
+
* function ProductFilters() {
|
|
209
|
+
* return (
|
|
210
|
+
* <FilteredCollection.Filters>
|
|
211
|
+
* {({ applyFilters, clearFilters, currentFilters, availableOptions, isFiltered }) => (
|
|
212
|
+
* <div className="filters">
|
|
213
|
+
* <h3>Filters</h3>
|
|
214
|
+
* <div className="price-filter">
|
|
215
|
+
* <label>Price Range</label>
|
|
216
|
+
* <input
|
|
217
|
+
* type="range"
|
|
218
|
+
* min={availableOptions.priceRange.min}
|
|
219
|
+
* max={availableOptions.priceRange.max}
|
|
220
|
+
* value={currentFilters.priceRange.min}
|
|
221
|
+
* onChange={(e) => applyFilters({
|
|
222
|
+
* ...currentFilters,
|
|
223
|
+
* priceRange: { ...currentFilters.priceRange, min: Number(e.target.value) }
|
|
224
|
+
* })}
|
|
225
|
+
* />
|
|
226
|
+
* </div>
|
|
227
|
+
* {isFiltered && (
|
|
228
|
+
* <button onClick={clearFilters}>Clear All Filters</button>
|
|
229
|
+
* )}
|
|
230
|
+
* </div>
|
|
231
|
+
* )}
|
|
232
|
+
* </FilteredCollection.Filters>
|
|
233
|
+
* );
|
|
234
|
+
* }
|
|
235
|
+
* ```
|
|
102
236
|
*/
|
|
103
237
|
export const Filters = ({ children }) => {
|
|
104
238
|
const collection = useService(CollectionServiceDefinition);
|
package/dist/react/Product.d.ts
CHANGED
|
@@ -17,6 +17,20 @@ export interface ProductNameRenderProps {
|
|
|
17
17
|
* Headless component for product name display
|
|
18
18
|
*
|
|
19
19
|
* @component
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { Product } from '@wix/stores/components';
|
|
23
|
+
*
|
|
24
|
+
* function ProductHeader() {
|
|
25
|
+
* return (
|
|
26
|
+
* <Product.Name>
|
|
27
|
+
* {({ name }) => (
|
|
28
|
+
* <h1>{name}</h1>
|
|
29
|
+
* )}
|
|
30
|
+
* </Product.Name>
|
|
31
|
+
* );
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
20
34
|
*/
|
|
21
35
|
export declare const Name: (props: ProductNameProps) => import("react").ReactNode;
|
|
22
36
|
/**
|
|
@@ -45,22 +59,33 @@ export interface ProductDescriptionRenderProps {
|
|
|
45
59
|
plainDescription: NonNullable<V3Product["plainDescription"]>;
|
|
46
60
|
}
|
|
47
61
|
/**
|
|
48
|
-
* Headless component for product description display
|
|
49
|
-
*
|
|
50
|
-
* @
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
|
|
62
|
+
* Headless component for product description display
|
|
63
|
+
*
|
|
64
|
+
* @component
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* import { Product } from '@wix/stores/components';
|
|
68
|
+
*
|
|
69
|
+
* function ProductDescription() {
|
|
70
|
+
* return (
|
|
71
|
+
* <Product.Description>
|
|
72
|
+
* {({ plainDescription, description }) => (
|
|
73
|
+
* <div>
|
|
74
|
+
* {plainDescription && (
|
|
75
|
+
* <div
|
|
76
|
+
* dangerouslySetInnerHTML={{
|
|
77
|
+
* __html: plainDescription,
|
|
78
|
+
* }}
|
|
79
|
+
* />
|
|
80
|
+
* )}
|
|
81
|
+
* {description && (
|
|
82
|
+
* <div>Rich content description available</div>
|
|
83
|
+
* )}
|
|
84
|
+
* </div>
|
|
85
|
+
* )}
|
|
86
|
+
* </Product.Description>
|
|
87
|
+
* );
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
66
91
|
export declare const Description: (props: ProductDescriptionProps) => import("react").ReactNode;
|
package/dist/react/Product.js
CHANGED
|
@@ -4,6 +4,20 @@ import { ProductServiceDefinition } from "../services/product-service.js";
|
|
|
4
4
|
* Headless component for product name display
|
|
5
5
|
*
|
|
6
6
|
* @component
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { Product } from '@wix/stores/components';
|
|
10
|
+
*
|
|
11
|
+
* function ProductHeader() {
|
|
12
|
+
* return (
|
|
13
|
+
* <Product.Name>
|
|
14
|
+
* {({ name }) => (
|
|
15
|
+
* <h1>{name}</h1>
|
|
16
|
+
* )}
|
|
17
|
+
* </Product.Name>
|
|
18
|
+
* );
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
7
21
|
*/
|
|
8
22
|
export const Name = (props) => {
|
|
9
23
|
const service = useService(ProductServiceDefinition);
|
|
@@ -14,24 +28,35 @@ export const Name = (props) => {
|
|
|
14
28
|
});
|
|
15
29
|
};
|
|
16
30
|
/**
|
|
17
|
-
* Headless component for product description display
|
|
18
|
-
*
|
|
19
|
-
* @
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
|
|
31
|
+
* Headless component for product description display
|
|
32
|
+
*
|
|
33
|
+
* @component
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* import { Product } from '@wix/stores/components';
|
|
37
|
+
*
|
|
38
|
+
* function ProductDescription() {
|
|
39
|
+
* return (
|
|
40
|
+
* <Product.Description>
|
|
41
|
+
* {({ plainDescription, description }) => (
|
|
42
|
+
* <div>
|
|
43
|
+
* {plainDescription && (
|
|
44
|
+
* <div
|
|
45
|
+
* dangerouslySetInnerHTML={{
|
|
46
|
+
* __html: plainDescription,
|
|
47
|
+
* }}
|
|
48
|
+
* />
|
|
49
|
+
* )}
|
|
50
|
+
* {description && (
|
|
51
|
+
* <div>Rich content description available</div>
|
|
52
|
+
* )}
|
|
53
|
+
* </div>
|
|
54
|
+
* )}
|
|
55
|
+
* </Product.Description>
|
|
56
|
+
* );
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
35
60
|
export const Description = (props) => {
|
|
36
61
|
const service = useService(ProductServiceDefinition);
|
|
37
62
|
const product = service.product.get();
|
|
@@ -36,5 +36,35 @@ export interface ActionsRenderProps {
|
|
|
36
36
|
* Headless component for product actions (add to cart, buy now)
|
|
37
37
|
*
|
|
38
38
|
* @component
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* import { ProductActions } from '@wix/stores/components';
|
|
42
|
+
*
|
|
43
|
+
* function AddToCartButton() {
|
|
44
|
+
* return (
|
|
45
|
+
* <ProductActions.Actions quantity={1}>
|
|
46
|
+
* {({ onAddToCart, onBuyNow, canAddToCart, isLoading, price, inStock, error }) => (
|
|
47
|
+
* <div>
|
|
48
|
+
* <div>Price: {price}</div>
|
|
49
|
+
* {error && <div className="error">{error}</div>}
|
|
50
|
+
* {!inStock && <div>Out of stock</div>}
|
|
51
|
+
* <button
|
|
52
|
+
* onClick={onAddToCart}
|
|
53
|
+
* disabled={!canAddToCart || isLoading}
|
|
54
|
+
* >
|
|
55
|
+
* {isLoading ? 'Adding...' : 'Add to Cart'}
|
|
56
|
+
* </button>
|
|
57
|
+
* <button
|
|
58
|
+
* onClick={onBuyNow}
|
|
59
|
+
* disabled={!canAddToCart || isLoading}
|
|
60
|
+
* >
|
|
61
|
+
* Buy Now
|
|
62
|
+
* </button>
|
|
63
|
+
* </div>
|
|
64
|
+
* )}
|
|
65
|
+
* </ProductActions.Actions>
|
|
66
|
+
* );
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
39
69
|
*/
|
|
40
70
|
export declare const Actions: (props: ActionsProps) => import("react").ReactNode;
|
|
@@ -6,6 +6,36 @@ import { CurrentCartServiceDefinition } from "@wix/headless-ecom/services";
|
|
|
6
6
|
* Headless component for product actions (add to cart, buy now)
|
|
7
7
|
*
|
|
8
8
|
* @component
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { ProductActions } from '@wix/stores/components';
|
|
12
|
+
*
|
|
13
|
+
* function AddToCartButton() {
|
|
14
|
+
* return (
|
|
15
|
+
* <ProductActions.Actions quantity={1}>
|
|
16
|
+
* {({ onAddToCart, onBuyNow, canAddToCart, isLoading, price, inStock, error }) => (
|
|
17
|
+
* <div>
|
|
18
|
+
* <div>Price: {price}</div>
|
|
19
|
+
* {error && <div className="error">{error}</div>}
|
|
20
|
+
* {!inStock && <div>Out of stock</div>}
|
|
21
|
+
* <button
|
|
22
|
+
* onClick={onAddToCart}
|
|
23
|
+
* disabled={!canAddToCart || isLoading}
|
|
24
|
+
* >
|
|
25
|
+
* {isLoading ? 'Adding...' : 'Add to Cart'}
|
|
26
|
+
* </button>
|
|
27
|
+
* <button
|
|
28
|
+
* onClick={onBuyNow}
|
|
29
|
+
* disabled={!canAddToCart || isLoading}
|
|
30
|
+
* >
|
|
31
|
+
* Buy Now
|
|
32
|
+
* </button>
|
|
33
|
+
* </div>
|
|
34
|
+
* )}
|
|
35
|
+
* </ProductActions.Actions>
|
|
36
|
+
* );
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
9
39
|
*/
|
|
10
40
|
export const Actions = (props) => {
|
|
11
41
|
const variantService = useService(SelectedVariantServiceDefinition);
|