@wix/headless-stores 0.0.110 → 0.0.111
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/astro/actions/custom-checkout.d.ts +1 -3
- package/cjs/dist/astro/actions/custom-checkout.js +8 -4
- package/cjs/dist/astro/actions/index.js +17 -1
- package/cjs/dist/data-component-tags.js +5 -2
- package/cjs/dist/enums/index.js +18 -2
- package/cjs/dist/enums/social-platform-enums.js +7 -4
- package/cjs/dist/enums/sort-enums.js +6 -3
- package/cjs/dist/react/Category.js +64 -25
- package/cjs/dist/react/CategoryList.js +55 -14
- package/cjs/dist/react/Choice.js +32 -25
- package/cjs/dist/react/Option.js +68 -29
- package/cjs/dist/react/Product.js +194 -155
- package/cjs/dist/react/ProductList.js +84 -45
- package/cjs/dist/react/core/CategoryList.js +26 -16
- package/cjs/dist/react/core/Product.js +30 -20
- package/cjs/dist/react/core/ProductList.js +29 -21
- package/cjs/dist/react/core/ProductListFilters.js +30 -22
- package/cjs/dist/react/core/ProductListPagination.js +7 -4
- package/cjs/dist/react/core/ProductListSort.js +11 -6
- package/cjs/dist/react/core/ProductModifiers.js +25 -17
- package/cjs/dist/react/core/ProductVariantSelector.js +27 -19
- package/cjs/dist/react/core/SelectedVariant.js +28 -21
- package/cjs/dist/react/index.js +42 -6
- package/cjs/dist/react/types.js +5 -2
- package/cjs/dist/server-actions/custom-checkout-action.js +11 -8
- package/cjs/dist/server-actions/index.js +17 -1
- package/cjs/dist/services/buy-now-service.js +20 -15
- package/cjs/dist/services/categories-list-service.js +12 -8
- package/cjs/dist/services/index.js +25 -5
- package/cjs/dist/services/pay-now-service.js +16 -11
- package/cjs/dist/services/product-modifiers-service.js +16 -12
- package/cjs/dist/services/product-service.js +16 -12
- package/cjs/dist/services/products-list-search-service.d.ts +0 -1
- package/cjs/dist/services/products-list-search-service.js +1 -1
- package/cjs/dist/services/products-list-service.js +66 -59
- package/cjs/dist/services/selected-variant-service.js +21 -18
- package/cjs/dist/utils/index.js +9 -6
- package/cjs/dist/utils/url-params.js +5 -1
- package/dist/astro/actions/custom-checkout.d.ts +1 -3
- package/package.json +5 -5
package/cjs/dist/react/Option.js
CHANGED
|
@@ -1,10 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ChoiceRepeater = exports.Choices = exports.MandatoryIndicator = exports.Name = exports.OptionContext = exports.Root = void 0;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
+
const react_1 = __importDefault(require("react"));
|
|
42
|
+
const Choice = __importStar(require("./Choice.js"));
|
|
43
|
+
const ProductModifiersPrimitive = __importStar(require("./core/ProductModifiers.js"));
|
|
44
|
+
const ProductVariantSelectorPrimitive = __importStar(require("./core/ProductVariantSelector.js"));
|
|
45
|
+
const react_2 = require("@wix/headless-utils/react");
|
|
46
|
+
const data_component_tags_js_1 = require("../data-component-tags.js");
|
|
8
47
|
var TestIds;
|
|
9
48
|
(function (TestIds) {
|
|
10
49
|
TestIds["optionRoot"] = "option-root";
|
|
@@ -93,7 +132,7 @@ var TestIds;
|
|
|
93
132
|
* </Option.Root>
|
|
94
133
|
* ```
|
|
95
134
|
*/
|
|
96
|
-
|
|
135
|
+
exports.Root = react_1.default.forwardRef((props, ref) => {
|
|
97
136
|
const { asChild, children, option, onValueChange, allowedTypes, className, ...otherProps } = props;
|
|
98
137
|
// Determine the option type based on the option name and available choices
|
|
99
138
|
const getOptionType = () => {
|
|
@@ -114,11 +153,11 @@ export const Root = React.forwardRef((props, ref) => {
|
|
|
114
153
|
allowedTypes,
|
|
115
154
|
mandatory: option?.mandatory || false,
|
|
116
155
|
};
|
|
117
|
-
return (
|
|
156
|
+
return ((0, jsx_runtime_1.jsx)(exports.OptionContext.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-component-tag": data_component_tags_js_1.DataComponentTags.optionRoot, "data-testid": TestIds.optionRoot, "data-type": optionType, customElement: children, customElementProps: { option, onValueChange, allowedTypes }, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { children: react_1.default.isValidElement(children) ? children : null }) }) }));
|
|
118
157
|
});
|
|
119
|
-
Root.displayName = 'Option.Root';
|
|
158
|
+
exports.Root.displayName = 'Option.Root';
|
|
120
159
|
// Create a context to pass option data down
|
|
121
|
-
|
|
160
|
+
exports.OptionContext = react_1.default.createContext(null);
|
|
122
161
|
/**
|
|
123
162
|
* Displays the option name.
|
|
124
163
|
* Follows true Radix pattern - use separate components for each styleable element.
|
|
@@ -142,13 +181,13 @@ export const OptionContext = React.createContext(null);
|
|
|
142
181
|
* </Option.Name>
|
|
143
182
|
* ```
|
|
144
183
|
*/
|
|
145
|
-
|
|
184
|
+
exports.Name = react_1.default.forwardRef((props, ref) => {
|
|
146
185
|
const { asChild, children, className, ...otherProps } = props;
|
|
147
|
-
const optionData =
|
|
186
|
+
const optionData = react_1.default.useContext(exports.OptionContext);
|
|
148
187
|
if (!optionData)
|
|
149
188
|
return null;
|
|
150
189
|
const name = optionData.name || '';
|
|
151
|
-
return (
|
|
190
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.optionName, customElement: children, customElementProps: { name }, content: name, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { children: name }) }));
|
|
152
191
|
});
|
|
153
192
|
/**
|
|
154
193
|
* Displays the mandatory indicator (asterisk) when the option is required.
|
|
@@ -168,16 +207,16 @@ export const Name = React.forwardRef((props, ref) => {
|
|
|
168
207
|
* </Option.MandatoryIndicator>
|
|
169
208
|
* ```
|
|
170
209
|
*/
|
|
171
|
-
|
|
210
|
+
exports.MandatoryIndicator = react_1.default.forwardRef((props, ref) => {
|
|
172
211
|
const { asChild, children, className } = props;
|
|
173
|
-
const optionData =
|
|
212
|
+
const optionData = react_1.default.useContext(exports.OptionContext);
|
|
174
213
|
if (!optionData)
|
|
175
214
|
return null;
|
|
176
215
|
const mandatory = optionData.mandatory || false;
|
|
177
216
|
// Don't render anything if not mandatory
|
|
178
217
|
if (!mandatory)
|
|
179
218
|
return null;
|
|
180
|
-
return (
|
|
219
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.optionMandatoryIndicator, customElement: children, customElementProps: { mandatory }, content: '*', children: (0, jsx_runtime_1.jsx)("span", { children: "*" }) }));
|
|
181
220
|
});
|
|
182
221
|
/**
|
|
183
222
|
* Container for the list items with empty state support.
|
|
@@ -210,9 +249,9 @@ export const MandatoryIndicator = React.forwardRef((props, ref) => {
|
|
|
210
249
|
* </Option.Choices>
|
|
211
250
|
* ```
|
|
212
251
|
*/
|
|
213
|
-
|
|
252
|
+
exports.Choices = react_1.default.forwardRef((props, ref) => {
|
|
214
253
|
const { children, emptyState } = props;
|
|
215
|
-
const optionData =
|
|
254
|
+
const optionData = react_1.default.useContext(exports.OptionContext);
|
|
216
255
|
if (!optionData)
|
|
217
256
|
return null;
|
|
218
257
|
// Check if we have choices to render (List Container Level pattern)
|
|
@@ -225,7 +264,7 @@ export const Choices = React.forwardRef((props, ref) => {
|
|
|
225
264
|
'data-testid': TestIds.optionChoices,
|
|
226
265
|
'data-type': optionData.optionType || 'text',
|
|
227
266
|
};
|
|
228
|
-
return (
|
|
267
|
+
return ((0, jsx_runtime_1.jsx)("div", { ...attributes, ref: ref, children: children }));
|
|
229
268
|
});
|
|
230
269
|
/**
|
|
231
270
|
* Repeater component that renders Choice.Root for each choice.
|
|
@@ -244,9 +283,9 @@ export const Choices = React.forwardRef((props, ref) => {
|
|
|
244
283
|
* </Option.ChoiceRepeater>
|
|
245
284
|
* ```
|
|
246
285
|
*/
|
|
247
|
-
|
|
286
|
+
exports.ChoiceRepeater = react_1.default.forwardRef((props, _ref) => {
|
|
248
287
|
const { children } = props;
|
|
249
|
-
const optionData =
|
|
288
|
+
const optionData = react_1.default.useContext(exports.OptionContext);
|
|
250
289
|
if (!optionData ||
|
|
251
290
|
(!optionData.choices?.length && optionData.optionType !== 'free-text'))
|
|
252
291
|
return null;
|
|
@@ -266,7 +305,7 @@ export const ChoiceRepeater = React.forwardRef((props, _ref) => {
|
|
|
266
305
|
...optionData,
|
|
267
306
|
type: 'free-text',
|
|
268
307
|
};
|
|
269
|
-
return (
|
|
308
|
+
return ((0, jsx_runtime_1.jsx)(ProductModifiersPrimitive.Choice, { modifier: optionData, choice: choice, children: (renderProps) => {
|
|
270
309
|
const { value, isSelected, select } = renderProps;
|
|
271
310
|
const contextValue = {
|
|
272
311
|
choice,
|
|
@@ -281,10 +320,10 @@ export const ChoiceRepeater = React.forwardRef((props, _ref) => {
|
|
|
281
320
|
select,
|
|
282
321
|
value,
|
|
283
322
|
};
|
|
284
|
-
return (
|
|
323
|
+
return ((0, jsx_runtime_1.jsx)(Choice.ChoiceContext.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(Choice.Root, { children: children }) }));
|
|
285
324
|
} }));
|
|
286
325
|
}
|
|
287
|
-
return (
|
|
326
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: optionData.choices.map((choice) => {
|
|
288
327
|
const choiceKey = choice.choiceId;
|
|
289
328
|
const getChoiceType = () => {
|
|
290
329
|
if (choice?.choiceType === 'ONE_COLOR')
|
|
@@ -302,7 +341,7 @@ export const ChoiceRepeater = React.forwardRef((props, _ref) => {
|
|
|
302
341
|
type: choiceType,
|
|
303
342
|
};
|
|
304
343
|
if (isModifier) {
|
|
305
|
-
return (
|
|
344
|
+
return ((0, jsx_runtime_1.jsx)(ProductModifiersPrimitive.Choice, { modifier: optionData, choice: choiceData, children: (renderProps) => {
|
|
306
345
|
const { value, isSelected, select } = renderProps;
|
|
307
346
|
const contextValue = {
|
|
308
347
|
choice: choiceData,
|
|
@@ -317,11 +356,11 @@ export const ChoiceRepeater = React.forwardRef((props, _ref) => {
|
|
|
317
356
|
select,
|
|
318
357
|
value,
|
|
319
358
|
};
|
|
320
|
-
return (
|
|
359
|
+
return ((0, jsx_runtime_1.jsx)(Choice.ChoiceContext.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(Choice.Root, { children: children }) }));
|
|
321
360
|
} }, choiceKey));
|
|
322
361
|
}
|
|
323
362
|
else {
|
|
324
|
-
return (
|
|
363
|
+
return ((0, jsx_runtime_1.jsx)(ProductVariantSelectorPrimitive.Choice, { option: optionData, choice: choiceData, children: (renderProps) => {
|
|
325
364
|
const { value, isSelected, select, isVisible, isInStock, isPreOrderEnabled, } = renderProps;
|
|
326
365
|
// Don't render if not visible
|
|
327
366
|
if (!isVisible)
|
|
@@ -339,7 +378,7 @@ export const ChoiceRepeater = React.forwardRef((props, _ref) => {
|
|
|
339
378
|
select,
|
|
340
379
|
value,
|
|
341
380
|
};
|
|
342
|
-
return (
|
|
381
|
+
return ((0, jsx_runtime_1.jsx)(Choice.ChoiceContext.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(Choice.Root, { children: children }) }));
|
|
343
382
|
} }, choiceKey));
|
|
344
383
|
}
|
|
345
384
|
}) }));
|