@wix/headless-stores 0.0.30 → 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 +101 -0
- package/cjs/dist/react/ProductsList.js +101 -0
- 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 +101 -0
- package/dist/react/ProductsList.js +101 -0
- 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
|
@@ -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;
|
|
@@ -17,6 +17,46 @@ function useModifiersService() {
|
|
|
17
17
|
* Headless component for all product modifiers
|
|
18
18
|
*
|
|
19
19
|
* @component
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { ProductModifiers } from '@wix/stores/components';
|
|
23
|
+
*
|
|
24
|
+
* function ModifiersSelector() {
|
|
25
|
+
* return (
|
|
26
|
+
* <ProductModifiers.Modifiers>
|
|
27
|
+
* {({ modifiers, hasModifiers, selectedModifiers, areAllRequiredModifiersFilled }) => (
|
|
28
|
+
* <div>
|
|
29
|
+
* {hasModifiers && (
|
|
30
|
+
* <div>
|
|
31
|
+
* <h3>Customize your product</h3>
|
|
32
|
+
* {modifiers.map(modifier => (
|
|
33
|
+
* <div key={modifier.id}>
|
|
34
|
+
* <label>{modifier.name}</label>
|
|
35
|
+
* {modifier.required && <span>*</span>}
|
|
36
|
+
* {modifier.choices?.map(choice => (
|
|
37
|
+
* <label key={choice.id}>
|
|
38
|
+
* <input
|
|
39
|
+
* type={modifier.multiple ? 'checkbox' : 'radio'}
|
|
40
|
+
* name={modifier.id}
|
|
41
|
+
* value={choice.id}
|
|
42
|
+
* checked={selectedModifiers[modifier.id] === choice.id}
|
|
43
|
+
* />
|
|
44
|
+
* {choice.description} (+{choice.priceChange?.price})
|
|
45
|
+
* </label>
|
|
46
|
+
* ))}
|
|
47
|
+
* </div>
|
|
48
|
+
* ))}
|
|
49
|
+
* {!areAllRequiredModifiersFilled && (
|
|
50
|
+
* <div className="warning">Please fill all required options</div>
|
|
51
|
+
* )}
|
|
52
|
+
* </div>
|
|
53
|
+
* )}
|
|
54
|
+
* </div>
|
|
55
|
+
* )}
|
|
56
|
+
* </ProductModifiers.Modifiers>
|
|
57
|
+
* );
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
20
60
|
*/
|
|
21
61
|
export const Modifiers = (props) => {
|
|
22
62
|
const modifiersService = useModifiersService();
|
|
@@ -43,6 +83,47 @@ export const Modifiers = (props) => {
|
|
|
43
83
|
* Headless component for a specific product modifier
|
|
44
84
|
*
|
|
45
85
|
* @component
|
|
86
|
+
* @example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* import { ProductModifiers } from '@wix/stores/components';
|
|
89
|
+
*
|
|
90
|
+
* function ModifierField({ modifier }) {
|
|
91
|
+
* return (
|
|
92
|
+
* <ProductModifiers.Modifier modifier={modifier}>
|
|
93
|
+
* {({ name, mandatory, hasChoices, choices, selectedValue, isFreeText, placeholder, maxChars }) => (
|
|
94
|
+
* <div className="modifier-field">
|
|
95
|
+
* <label>
|
|
96
|
+
* {name} {mandatory && <span className="required">*</span>}
|
|
97
|
+
* </label>
|
|
98
|
+
* {hasChoices && (
|
|
99
|
+
* <div className="choices">
|
|
100
|
+
* {choices.map(choice => (
|
|
101
|
+
* <label key={choice.id}>
|
|
102
|
+
* <input
|
|
103
|
+
* type="radio"
|
|
104
|
+
* name={name}
|
|
105
|
+
* value={choice.name}
|
|
106
|
+
* checked={selectedValue?.choiceValue === choice.name}
|
|
107
|
+
* />
|
|
108
|
+
* {choice.description} (+{choice.priceChange?.price || '0'})
|
|
109
|
+
* </label>
|
|
110
|
+
* ))}
|
|
111
|
+
* </div>
|
|
112
|
+
* )}
|
|
113
|
+
* {isFreeText && (
|
|
114
|
+
* <input
|
|
115
|
+
* type="text"
|
|
116
|
+
* placeholder={placeholder}
|
|
117
|
+
* maxLength={maxChars}
|
|
118
|
+
* value={selectedValue?.freeTextValue || ''}
|
|
119
|
+
* />
|
|
120
|
+
* )}
|
|
121
|
+
* </div>
|
|
122
|
+
* )}
|
|
123
|
+
* </ProductModifiers.Modifier>
|
|
124
|
+
* );
|
|
125
|
+
* }
|
|
126
|
+
* ```
|
|
46
127
|
*/
|
|
47
128
|
export const Modifier = (props) => {
|
|
48
129
|
const modifiersService = useModifiersService();
|
|
@@ -73,6 +154,31 @@ export const Modifier = (props) => {
|
|
|
73
154
|
* Headless component for individual modifier choice selection
|
|
74
155
|
*
|
|
75
156
|
* @component
|
|
157
|
+
* @example
|
|
158
|
+
* ```tsx
|
|
159
|
+
* import { ProductModifiers } from '@wix/stores/components';
|
|
160
|
+
*
|
|
161
|
+
* function ModifierChoiceButton({ modifier, choice }) {
|
|
162
|
+
* return (
|
|
163
|
+
* <ProductModifiers.Choice modifier={modifier} choice={choice}>
|
|
164
|
+
* {({ value, description, isSelected, onSelect, colorCode }) => (
|
|
165
|
+
* <button
|
|
166
|
+
* onClick={onSelect}
|
|
167
|
+
* className={`choice-button ${isSelected ? 'selected' : ''}`}
|
|
168
|
+
* style={colorCode ? { backgroundColor: colorCode } : {}}
|
|
169
|
+
* >
|
|
170
|
+
* {colorCode ? (
|
|
171
|
+
* <div className="color-swatch" title={value} />
|
|
172
|
+
* ) : (
|
|
173
|
+
* <span>{value}</span>
|
|
174
|
+
* )}
|
|
175
|
+
* {description && <span className="description">{description}</span>}
|
|
176
|
+
* </button>
|
|
177
|
+
* )}
|
|
178
|
+
* </ProductModifiers.Choice>
|
|
179
|
+
* );
|
|
180
|
+
* }
|
|
181
|
+
* ```
|
|
76
182
|
*/
|
|
77
183
|
export const Choice = (props) => {
|
|
78
184
|
const modifiersService = useModifiersService();
|
|
@@ -105,6 +211,36 @@ export const Choice = (props) => {
|
|
|
105
211
|
* Headless component for free text modifier input
|
|
106
212
|
*
|
|
107
213
|
* @component
|
|
214
|
+
* @example
|
|
215
|
+
* ```tsx
|
|
216
|
+
* import { ProductModifiers } from '@wix/stores/components';
|
|
217
|
+
*
|
|
218
|
+
* function FreeTextModifier({ modifier }) {
|
|
219
|
+
* return (
|
|
220
|
+
* <ProductModifiers.FreeText modifier={modifier}>
|
|
221
|
+
* {({ value, onChange, mandatory, maxChars, placeholder, charCount, isOverLimit, modifierName }) => (
|
|
222
|
+
* <div className="free-text-modifier">
|
|
223
|
+
* <label>
|
|
224
|
+
* {modifierName} {mandatory && <span className="required">*</span>}
|
|
225
|
+
* </label>
|
|
226
|
+
* <textarea
|
|
227
|
+
* value={value}
|
|
228
|
+
* onChange={(e) => onChange(e.target.value)}
|
|
229
|
+
* placeholder={placeholder}
|
|
230
|
+
* maxLength={maxChars}
|
|
231
|
+
* className={isOverLimit ? 'over-limit' : ''}
|
|
232
|
+
* />
|
|
233
|
+
* {maxChars && (
|
|
234
|
+
* <div className={`char-count ${isOverLimit ? 'over-limit' : ''}`}>
|
|
235
|
+
* {charCount}/{maxChars}
|
|
236
|
+
* </div>
|
|
237
|
+
* )}
|
|
238
|
+
* </div>
|
|
239
|
+
* )}
|
|
240
|
+
* </ProductModifiers.FreeText>
|
|
241
|
+
* );
|
|
242
|
+
* }
|
|
243
|
+
* ```
|
|
108
244
|
*/
|
|
109
245
|
export const FreeText = (props) => {
|
|
110
246
|
const modifiersService = useModifiersService();
|
|
@@ -139,6 +275,42 @@ export const FreeText = (props) => {
|
|
|
139
275
|
* Used for optional free text modifiers where a checkbox shows/hides the input
|
|
140
276
|
*
|
|
141
277
|
* @component
|
|
278
|
+
* @example
|
|
279
|
+
* ```tsx
|
|
280
|
+
* import { ProductModifiers } from '@wix/stores/components';
|
|
281
|
+
*
|
|
282
|
+
* function ToggleFreeTextModifier({ modifier }) {
|
|
283
|
+
* return (
|
|
284
|
+
* <ProductModifiers.ToggleFreeText modifier={modifier}>
|
|
285
|
+
* {({ isTextInputShown, onToggle, mandatory, modifierName }) => (
|
|
286
|
+
* <div className="toggle-free-text">
|
|
287
|
+
* {!mandatory && (
|
|
288
|
+
* <label>
|
|
289
|
+
* <input
|
|
290
|
+
* type="checkbox"
|
|
291
|
+
* checked={isTextInputShown}
|
|
292
|
+
* onChange={onToggle}
|
|
293
|
+
* />
|
|
294
|
+
* Add {modifierName}
|
|
295
|
+
* </label>
|
|
296
|
+
* )}
|
|
297
|
+
* {isTextInputShown && (
|
|
298
|
+
* <ProductModifiers.FreeText modifier={modifier}>
|
|
299
|
+
* {(props) => (
|
|
300
|
+
* <textarea
|
|
301
|
+
* value={props.value}
|
|
302
|
+
* onChange={(e) => props.onChange(e.target.value)}
|
|
303
|
+
* placeholder={props.placeholder}
|
|
304
|
+
* />
|
|
305
|
+
* )}
|
|
306
|
+
* </ProductModifiers.FreeText>
|
|
307
|
+
* )}
|
|
308
|
+
* </div>
|
|
309
|
+
* )}
|
|
310
|
+
* </ProductModifiers.ToggleFreeText>
|
|
311
|
+
* );
|
|
312
|
+
* }
|
|
313
|
+
* ```
|
|
142
314
|
*/
|
|
143
315
|
export const ToggleFreeText = (props) => {
|
|
144
316
|
const modifiersService = useModifiersService();
|
|
@@ -21,6 +21,33 @@ export interface OptionsRenderProps {
|
|
|
21
21
|
* Headless component for all product options
|
|
22
22
|
*
|
|
23
23
|
* @component
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* import { ProductVariantSelector } from '@wix/stores/components';
|
|
27
|
+
*
|
|
28
|
+
* function VariantPicker() {
|
|
29
|
+
* return (
|
|
30
|
+
* <ProductVariantSelector.Options>
|
|
31
|
+
* {({ options, hasOptions, selectedChoices }) => (
|
|
32
|
+
* <div>
|
|
33
|
+
* {hasOptions && options.map(option => (
|
|
34
|
+
* <div key={option.id}>
|
|
35
|
+
* <label>{option.name}</label>
|
|
36
|
+
* <select value={selectedChoices[option.id] || ''}>
|
|
37
|
+
* {option.choices?.map(choice => (
|
|
38
|
+
* <option key={choice.id} value={choice.id}>
|
|
39
|
+
* {choice.description}
|
|
40
|
+
* </option>
|
|
41
|
+
* ))}
|
|
42
|
+
* </select>
|
|
43
|
+
* </div>
|
|
44
|
+
* ))}
|
|
45
|
+
* </div>
|
|
46
|
+
* )}
|
|
47
|
+
* </ProductVariantSelector.Options>
|
|
48
|
+
* );
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
24
51
|
*/
|
|
25
52
|
export declare const Options: (props: OptionsProps) => import("react").ReactNode;
|
|
26
53
|
/**
|
|
@@ -51,6 +78,32 @@ export interface OptionRenderProps {
|
|
|
51
78
|
* Headless component for choices within a specific product option
|
|
52
79
|
*
|
|
53
80
|
* @component
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* import { ProductVariantSelector } from '@wix/stores/components';
|
|
84
|
+
*
|
|
85
|
+
* function OptionSelector({ option }) {
|
|
86
|
+
* return (
|
|
87
|
+
* <ProductVariantSelector.Option option={option}>
|
|
88
|
+
* {({ name, choices, selectedValue, hasChoices }) => (
|
|
89
|
+
* <div>
|
|
90
|
+
* <label>{name}</label>
|
|
91
|
+
* {hasChoices && (
|
|
92
|
+
* <select value={selectedValue || ''}>
|
|
93
|
+
* <option value="">Select {name}</option>
|
|
94
|
+
* {choices.map(choice => (
|
|
95
|
+
* <option key={choice.id} value={choice.name}>
|
|
96
|
+
* {choice.description}
|
|
97
|
+
* </option>
|
|
98
|
+
* ))}
|
|
99
|
+
* </select>
|
|
100
|
+
* )}
|
|
101
|
+
* </div>
|
|
102
|
+
* )}
|
|
103
|
+
* </ProductVariantSelector.Option>
|
|
104
|
+
* );
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
54
107
|
*/
|
|
55
108
|
export declare const Option: (props: OptionProps) => import("react").ReactNode;
|
|
56
109
|
/**
|
|
@@ -91,6 +144,27 @@ export interface ChoiceRenderProps {
|
|
|
91
144
|
* Headless component for individual choice selection
|
|
92
145
|
*
|
|
93
146
|
* @component
|
|
147
|
+
* @example
|
|
148
|
+
* ```tsx
|
|
149
|
+
* import { ProductVariantSelector } from '@wix/stores/components';
|
|
150
|
+
*
|
|
151
|
+
* function ChoiceButton({ option, choice }) {
|
|
152
|
+
* return (
|
|
153
|
+
* <ProductVariantSelector.Choice option={option} choice={choice}>
|
|
154
|
+
* {({ value, isSelected, isVisible, isInStock, onSelect }) => (
|
|
155
|
+
* <button
|
|
156
|
+
* onClick={onSelect}
|
|
157
|
+
* disabled={!isVisible || !isInStock}
|
|
158
|
+
* className={`choice-btn ${isSelected ? 'selected' : ''} ${!isInStock ? 'out-of-stock' : ''}`}
|
|
159
|
+
* >
|
|
160
|
+
* {value}
|
|
161
|
+
* {!isInStock && ' (Out of Stock)'}
|
|
162
|
+
* </button>
|
|
163
|
+
* )}
|
|
164
|
+
* </ProductVariantSelector.Choice>
|
|
165
|
+
* );
|
|
166
|
+
* }
|
|
167
|
+
* ```
|
|
94
168
|
*/
|
|
95
169
|
export declare const Choice: (props: ChoiceProps) => import("react").ReactNode;
|
|
96
170
|
/**
|
|
@@ -127,6 +201,32 @@ export interface StockRenderProps {
|
|
|
127
201
|
* Headless component for product stock status
|
|
128
202
|
*
|
|
129
203
|
* @component
|
|
204
|
+
* @example
|
|
205
|
+
* ```tsx
|
|
206
|
+
* import { ProductVariantSelector } from '@wix/stores/components';
|
|
207
|
+
*
|
|
208
|
+
* function StockIndicator() {
|
|
209
|
+
* return (
|
|
210
|
+
* <ProductVariantSelector.Stock>
|
|
211
|
+
* {({ inStock, isPreOrderEnabled, selectedQuantity, availableQuantity, incrementQuantity, decrementQuantity }) => (
|
|
212
|
+
* <div>
|
|
213
|
+
* <div className={`stock-status ${inStock ? 'in-stock' : 'out-of-stock'}`}>
|
|
214
|
+
* {inStock ? 'In Stock' : isPreOrderEnabled ? 'Pre-order Available' : 'Out of Stock'}
|
|
215
|
+
* </div>
|
|
216
|
+
* {availableQuantity && (
|
|
217
|
+
* <div>Only {availableQuantity} left!</div>
|
|
218
|
+
* )}
|
|
219
|
+
* <div className="quantity-selector">
|
|
220
|
+
* <button onClick={decrementQuantity}>-</button>
|
|
221
|
+
* <span>{selectedQuantity}</span>
|
|
222
|
+
* <button onClick={incrementQuantity}>+</button>
|
|
223
|
+
* </div>
|
|
224
|
+
* </div>
|
|
225
|
+
* )}
|
|
226
|
+
* </ProductVariantSelector.Stock>
|
|
227
|
+
* );
|
|
228
|
+
* }
|
|
229
|
+
* ```
|
|
130
230
|
*/
|
|
131
231
|
export declare const Stock: (props: StockProps) => import("react").ReactNode;
|
|
132
232
|
/**
|
|
@@ -149,5 +249,23 @@ export interface ResetRenderProps {
|
|
|
149
249
|
* Headless component for resetting variant selections
|
|
150
250
|
*
|
|
151
251
|
* @component
|
|
252
|
+
* @example
|
|
253
|
+
* ```tsx
|
|
254
|
+
* import { ProductVariantSelector } from '@wix/stores/components';
|
|
255
|
+
*
|
|
256
|
+
* function ResetButton() {
|
|
257
|
+
* return (
|
|
258
|
+
* <ProductVariantSelector.Reset>
|
|
259
|
+
* {({ onReset, hasSelections }) => (
|
|
260
|
+
* hasSelections && (
|
|
261
|
+
* <button onClick={onReset} className="reset-button">
|
|
262
|
+
* Clear All Selections
|
|
263
|
+
* </button>
|
|
264
|
+
* )
|
|
265
|
+
* )}
|
|
266
|
+
* </ProductVariantSelector.Reset>
|
|
267
|
+
* );
|
|
268
|
+
* }
|
|
269
|
+
* ```
|
|
152
270
|
*/
|
|
153
271
|
export declare const Reset: (props: ResetProps) => import("react").ReactNode;
|