@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
|
@@ -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);
|
|
@@ -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;
|
|
@@ -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);
|
|
@@ -23,6 +23,46 @@ export interface ModifiersRenderProps {
|
|
|
23
23
|
* Headless component for all product modifiers
|
|
24
24
|
*
|
|
25
25
|
* @component
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* import { ProductModifiers } from '@wix/stores/components';
|
|
29
|
+
*
|
|
30
|
+
* function ModifiersSelector() {
|
|
31
|
+
* return (
|
|
32
|
+
* <ProductModifiers.Modifiers>
|
|
33
|
+
* {({ modifiers, hasModifiers, selectedModifiers, areAllRequiredModifiersFilled }) => (
|
|
34
|
+
* <div>
|
|
35
|
+
* {hasModifiers && (
|
|
36
|
+
* <div>
|
|
37
|
+
* <h3>Customize your product</h3>
|
|
38
|
+
* {modifiers.map(modifier => (
|
|
39
|
+
* <div key={modifier.id}>
|
|
40
|
+
* <label>{modifier.name}</label>
|
|
41
|
+
* {modifier.required && <span>*</span>}
|
|
42
|
+
* {modifier.choices?.map(choice => (
|
|
43
|
+
* <label key={choice.id}>
|
|
44
|
+
* <input
|
|
45
|
+
* type={modifier.multiple ? 'checkbox' : 'radio'}
|
|
46
|
+
* name={modifier.id}
|
|
47
|
+
* value={choice.id}
|
|
48
|
+
* checked={selectedModifiers[modifier.id] === choice.id}
|
|
49
|
+
* />
|
|
50
|
+
* {choice.description} (+{choice.priceChange?.price})
|
|
51
|
+
* </label>
|
|
52
|
+
* ))}
|
|
53
|
+
* </div>
|
|
54
|
+
* ))}
|
|
55
|
+
* {!areAllRequiredModifiersFilled && (
|
|
56
|
+
* <div className="warning">Please fill all required options</div>
|
|
57
|
+
* )}
|
|
58
|
+
* </div>
|
|
59
|
+
* )}
|
|
60
|
+
* </div>
|
|
61
|
+
* )}
|
|
62
|
+
* </ProductModifiers.Modifiers>
|
|
63
|
+
* );
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
26
66
|
*/
|
|
27
67
|
export declare const Modifiers: (props: ModifiersProps) => import("react").ReactNode;
|
|
28
68
|
/**
|
|
@@ -61,6 +101,47 @@ export interface ModifierRenderProps {
|
|
|
61
101
|
* Headless component for a specific product modifier
|
|
62
102
|
*
|
|
63
103
|
* @component
|
|
104
|
+
* @example
|
|
105
|
+
* ```tsx
|
|
106
|
+
* import { ProductModifiers } from '@wix/stores/components';
|
|
107
|
+
*
|
|
108
|
+
* function ModifierField({ modifier }) {
|
|
109
|
+
* return (
|
|
110
|
+
* <ProductModifiers.Modifier modifier={modifier}>
|
|
111
|
+
* {({ name, mandatory, hasChoices, choices, selectedValue, isFreeText, placeholder, maxChars }) => (
|
|
112
|
+
* <div className="modifier-field">
|
|
113
|
+
* <label>
|
|
114
|
+
* {name} {mandatory && <span className="required">*</span>}
|
|
115
|
+
* </label>
|
|
116
|
+
* {hasChoices && (
|
|
117
|
+
* <div className="choices">
|
|
118
|
+
* {choices.map(choice => (
|
|
119
|
+
* <label key={choice.id}>
|
|
120
|
+
* <input
|
|
121
|
+
* type="radio"
|
|
122
|
+
* name={name}
|
|
123
|
+
* value={choice.name}
|
|
124
|
+
* checked={selectedValue?.choiceValue === choice.name}
|
|
125
|
+
* />
|
|
126
|
+
* {choice.description} (+{choice.priceChange?.price || '0'})
|
|
127
|
+
* </label>
|
|
128
|
+
* ))}
|
|
129
|
+
* </div>
|
|
130
|
+
* )}
|
|
131
|
+
* {isFreeText && (
|
|
132
|
+
* <input
|
|
133
|
+
* type="text"
|
|
134
|
+
* placeholder={placeholder}
|
|
135
|
+
* maxLength={maxChars}
|
|
136
|
+
* value={selectedValue?.freeTextValue || ''}
|
|
137
|
+
* />
|
|
138
|
+
* )}
|
|
139
|
+
* </div>
|
|
140
|
+
* )}
|
|
141
|
+
* </ProductModifiers.Modifier>
|
|
142
|
+
* );
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
64
145
|
*/
|
|
65
146
|
export declare const Modifier: (props: ModifierProps) => import("react").ReactNode;
|
|
66
147
|
/**
|
|
@@ -97,6 +178,31 @@ export interface ChoiceRenderProps {
|
|
|
97
178
|
* Headless component for individual modifier choice selection
|
|
98
179
|
*
|
|
99
180
|
* @component
|
|
181
|
+
* @example
|
|
182
|
+
* ```tsx
|
|
183
|
+
* import { ProductModifiers } from '@wix/stores/components';
|
|
184
|
+
*
|
|
185
|
+
* function ModifierChoiceButton({ modifier, choice }) {
|
|
186
|
+
* return (
|
|
187
|
+
* <ProductModifiers.Choice modifier={modifier} choice={choice}>
|
|
188
|
+
* {({ value, description, isSelected, onSelect, colorCode }) => (
|
|
189
|
+
* <button
|
|
190
|
+
* onClick={onSelect}
|
|
191
|
+
* className={`choice-button ${isSelected ? 'selected' : ''}`}
|
|
192
|
+
* style={colorCode ? { backgroundColor: colorCode } : {}}
|
|
193
|
+
* >
|
|
194
|
+
* {colorCode ? (
|
|
195
|
+
* <div className="color-swatch" title={value} />
|
|
196
|
+
* ) : (
|
|
197
|
+
* <span>{value}</span>
|
|
198
|
+
* )}
|
|
199
|
+
* {description && <span className="description">{description}</span>}
|
|
200
|
+
* </button>
|
|
201
|
+
* )}
|
|
202
|
+
* </ProductModifiers.Choice>
|
|
203
|
+
* );
|
|
204
|
+
* }
|
|
205
|
+
* ```
|
|
100
206
|
*/
|
|
101
207
|
export declare const Choice: (props: ChoiceProps) => import("react").ReactNode;
|
|
102
208
|
/**
|
|
@@ -133,6 +239,36 @@ export interface FreeTextRenderProps {
|
|
|
133
239
|
* Headless component for free text modifier input
|
|
134
240
|
*
|
|
135
241
|
* @component
|
|
242
|
+
* @example
|
|
243
|
+
* ```tsx
|
|
244
|
+
* import { ProductModifiers } from '@wix/stores/components';
|
|
245
|
+
*
|
|
246
|
+
* function FreeTextModifier({ modifier }) {
|
|
247
|
+
* return (
|
|
248
|
+
* <ProductModifiers.FreeText modifier={modifier}>
|
|
249
|
+
* {({ value, onChange, mandatory, maxChars, placeholder, charCount, isOverLimit, modifierName }) => (
|
|
250
|
+
* <div className="free-text-modifier">
|
|
251
|
+
* <label>
|
|
252
|
+
* {modifierName} {mandatory && <span className="required">*</span>}
|
|
253
|
+
* </label>
|
|
254
|
+
* <textarea
|
|
255
|
+
* value={value}
|
|
256
|
+
* onChange={(e) => onChange(e.target.value)}
|
|
257
|
+
* placeholder={placeholder}
|
|
258
|
+
* maxLength={maxChars}
|
|
259
|
+
* className={isOverLimit ? 'over-limit' : ''}
|
|
260
|
+
* />
|
|
261
|
+
* {maxChars && (
|
|
262
|
+
* <div className={`char-count ${isOverLimit ? 'over-limit' : ''}`}>
|
|
263
|
+
* {charCount}/{maxChars}
|
|
264
|
+
* </div>
|
|
265
|
+
* )}
|
|
266
|
+
* </div>
|
|
267
|
+
* )}
|
|
268
|
+
* </ProductModifiers.FreeText>
|
|
269
|
+
* );
|
|
270
|
+
* }
|
|
271
|
+
* ```
|
|
136
272
|
*/
|
|
137
273
|
export declare const FreeText: (props: FreeTextProps) => import("react").ReactNode;
|
|
138
274
|
/**
|
|
@@ -162,5 +298,41 @@ export interface ToggleFreeTextRenderProps {
|
|
|
162
298
|
* Used for optional free text modifiers where a checkbox shows/hides the input
|
|
163
299
|
*
|
|
164
300
|
* @component
|
|
301
|
+
* @example
|
|
302
|
+
* ```tsx
|
|
303
|
+
* import { ProductModifiers } from '@wix/stores/components';
|
|
304
|
+
*
|
|
305
|
+
* function ToggleFreeTextModifier({ modifier }) {
|
|
306
|
+
* return (
|
|
307
|
+
* <ProductModifiers.ToggleFreeText modifier={modifier}>
|
|
308
|
+
* {({ isTextInputShown, onToggle, mandatory, modifierName }) => (
|
|
309
|
+
* <div className="toggle-free-text">
|
|
310
|
+
* {!mandatory && (
|
|
311
|
+
* <label>
|
|
312
|
+
* <input
|
|
313
|
+
* type="checkbox"
|
|
314
|
+
* checked={isTextInputShown}
|
|
315
|
+
* onChange={onToggle}
|
|
316
|
+
* />
|
|
317
|
+
* Add {modifierName}
|
|
318
|
+
* </label>
|
|
319
|
+
* )}
|
|
320
|
+
* {isTextInputShown && (
|
|
321
|
+
* <ProductModifiers.FreeText modifier={modifier}>
|
|
322
|
+
* {(props) => (
|
|
323
|
+
* <textarea
|
|
324
|
+
* value={props.value}
|
|
325
|
+
* onChange={(e) => props.onChange(e.target.value)}
|
|
326
|
+
* placeholder={props.placeholder}
|
|
327
|
+
* />
|
|
328
|
+
* )}
|
|
329
|
+
* </ProductModifiers.FreeText>
|
|
330
|
+
* )}
|
|
331
|
+
* </div>
|
|
332
|
+
* )}
|
|
333
|
+
* </ProductModifiers.ToggleFreeText>
|
|
334
|
+
* );
|
|
335
|
+
* }
|
|
336
|
+
* ```
|
|
165
337
|
*/
|
|
166
338
|
export declare const ToggleFreeText: (props: ToggleFreeTextProps) => import("react").ReactNode;
|