@betterstore/react 0.3.2 → 0.3.3
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/CHANGELOG.md +6 -0
- package/dist/components/cart/useCart.d.ts +7 -3
- package/dist/index.cjs.js +5 -19
- package/dist/index.mjs +5 -19
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { Product,
|
|
1
|
+
import { Product, LineItemCreate as SDKLineItem } from "@betterstore/sdk";
|
|
2
|
+
type RecursiveRecord = {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
};
|
|
2
5
|
type LineItemOptionalParams = {
|
|
3
6
|
quantity?: number;
|
|
4
7
|
variantOptions?: {
|
|
5
8
|
name: string;
|
|
6
9
|
value: string;
|
|
7
10
|
}[];
|
|
8
|
-
metadata?:
|
|
11
|
+
metadata?: RecursiveRecord;
|
|
9
12
|
};
|
|
10
|
-
interface LineItem extends
|
|
13
|
+
interface LineItem extends Pick<SDKLineItem, "metadata" | "quantity" | "variantOptions" | "product"> {
|
|
11
14
|
id: string;
|
|
15
|
+
productId: string;
|
|
12
16
|
}
|
|
13
17
|
interface Cart {
|
|
14
18
|
lineItems: LineItem[];
|
package/dist/index.cjs.js
CHANGED
|
@@ -12712,7 +12712,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
12712
12712
|
* and warn against mismatches.
|
|
12713
12713
|
*/
|
|
12714
12714
|
if (process.env.NODE_ENV === "development") {
|
|
12715
|
-
warnOnce(nextValue.version === "12.9.
|
|
12715
|
+
warnOnce(nextValue.version === "12.9.2", `Attempting to mix Motion versions ${nextValue.version} with 12.9.2 may not work as expected.`);
|
|
12716
12716
|
}
|
|
12717
12717
|
}
|
|
12718
12718
|
else if (isMotionValue(prevValue)) {
|
|
@@ -34469,16 +34469,9 @@ function CheckoutSummary({ lineItems, shipping, tax, currency, onCancel, exchang
|
|
|
34469
34469
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
34470
34470
|
const { t } = useTranslation();
|
|
34471
34471
|
const subtotal = lineItems.reduce((acc, item) => {
|
|
34472
|
-
var _a
|
|
34473
|
-
const
|
|
34474
|
-
|
|
34475
|
-
return false;
|
|
34476
|
-
if (variant.variantOptions.length !== item.variantOptions.length)
|
|
34477
|
-
return false;
|
|
34478
|
-
return variant.variantOptions.every((vOpt) => item.variantOptions.some((iOpt) => vOpt.name === iOpt.name && vOpt.value === iOpt.value));
|
|
34479
|
-
});
|
|
34480
|
-
const productItem = variant || item.product;
|
|
34481
|
-
return acc + ((_b = productItem === null || productItem === void 0 ? void 0 : productItem.priceInCents) !== null && _b !== void 0 ? _b : 0) * item.quantity;
|
|
34472
|
+
var _a;
|
|
34473
|
+
const productItem = item.product.selectedVariant || item.product;
|
|
34474
|
+
return acc + ((_a = productItem === null || productItem === void 0 ? void 0 : productItem.priceInCents) !== null && _a !== void 0 ? _a : 0) * item.quantity;
|
|
34482
34475
|
}, 0);
|
|
34483
34476
|
const shippingPrice = shipping !== null && shipping !== void 0 ? shipping : (_a = formData.shipping) === null || _a === void 0 ? void 0 : _a.price;
|
|
34484
34477
|
const total = subtotal + (tax !== null && tax !== void 0 ? tax : 0) + (shippingPrice !== null && shippingPrice !== void 0 ? shippingPrice : 0);
|
|
@@ -34519,14 +34512,7 @@ function CheckoutSummary({ lineItems, shipping, tax, currency, onCancel, exchang
|
|
|
34519
34512
|
grid: isOpen,
|
|
34520
34513
|
}) }, lineItems.map((item, index) => {
|
|
34521
34514
|
var _a, _b, _c, _d, _e;
|
|
34522
|
-
const
|
|
34523
|
-
if (!variant.variantOptions || !item.variantOptions)
|
|
34524
|
-
return false;
|
|
34525
|
-
if (variant.variantOptions.length !== item.variantOptions.length)
|
|
34526
|
-
return false;
|
|
34527
|
-
return variant.variantOptions.every((vOpt) => item.variantOptions.some((iOpt) => vOpt.name === iOpt.name && vOpt.value === iOpt.value));
|
|
34528
|
-
});
|
|
34529
|
-
const productItem = variant || item.product;
|
|
34515
|
+
const productItem = ((_a = item.product) === null || _a === void 0 ? void 0 : _a.selectedVariant) || item.product;
|
|
34530
34516
|
return (React.createElement("div", { key: index, className: "flex items-center" },
|
|
34531
34517
|
React.createElement("div", { className: "relative" },
|
|
34532
34518
|
React.createElement("div", { className: "w-16 h-16 bg-secondary rounded-lg overflow-hidden relative" }, (productItem === null || productItem === void 0 ? void 0 : productItem.images[0]) && (React.createElement("img", { src: productItem.images[0] ||
|
package/dist/index.mjs
CHANGED
|
@@ -12689,7 +12689,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
12689
12689
|
* and warn against mismatches.
|
|
12690
12690
|
*/
|
|
12691
12691
|
if (process.env.NODE_ENV === "development") {
|
|
12692
|
-
warnOnce(nextValue.version === "12.9.
|
|
12692
|
+
warnOnce(nextValue.version === "12.9.2", `Attempting to mix Motion versions ${nextValue.version} with 12.9.2 may not work as expected.`);
|
|
12693
12693
|
}
|
|
12694
12694
|
}
|
|
12695
12695
|
else if (isMotionValue(prevValue)) {
|
|
@@ -34446,16 +34446,9 @@ function CheckoutSummary({ lineItems, shipping, tax, currency, onCancel, exchang
|
|
|
34446
34446
|
const [isOpen, setIsOpen] = useState(false);
|
|
34447
34447
|
const { t } = useTranslation();
|
|
34448
34448
|
const subtotal = lineItems.reduce((acc, item) => {
|
|
34449
|
-
var _a
|
|
34450
|
-
const
|
|
34451
|
-
|
|
34452
|
-
return false;
|
|
34453
|
-
if (variant.variantOptions.length !== item.variantOptions.length)
|
|
34454
|
-
return false;
|
|
34455
|
-
return variant.variantOptions.every((vOpt) => item.variantOptions.some((iOpt) => vOpt.name === iOpt.name && vOpt.value === iOpt.value));
|
|
34456
|
-
});
|
|
34457
|
-
const productItem = variant || item.product;
|
|
34458
|
-
return acc + ((_b = productItem === null || productItem === void 0 ? void 0 : productItem.priceInCents) !== null && _b !== void 0 ? _b : 0) * item.quantity;
|
|
34449
|
+
var _a;
|
|
34450
|
+
const productItem = item.product.selectedVariant || item.product;
|
|
34451
|
+
return acc + ((_a = productItem === null || productItem === void 0 ? void 0 : productItem.priceInCents) !== null && _a !== void 0 ? _a : 0) * item.quantity;
|
|
34459
34452
|
}, 0);
|
|
34460
34453
|
const shippingPrice = shipping !== null && shipping !== void 0 ? shipping : (_a = formData.shipping) === null || _a === void 0 ? void 0 : _a.price;
|
|
34461
34454
|
const total = subtotal + (tax !== null && tax !== void 0 ? tax : 0) + (shippingPrice !== null && shippingPrice !== void 0 ? shippingPrice : 0);
|
|
@@ -34496,14 +34489,7 @@ function CheckoutSummary({ lineItems, shipping, tax, currency, onCancel, exchang
|
|
|
34496
34489
|
grid: isOpen,
|
|
34497
34490
|
}) }, lineItems.map((item, index) => {
|
|
34498
34491
|
var _a, _b, _c, _d, _e;
|
|
34499
|
-
const
|
|
34500
|
-
if (!variant.variantOptions || !item.variantOptions)
|
|
34501
|
-
return false;
|
|
34502
|
-
if (variant.variantOptions.length !== item.variantOptions.length)
|
|
34503
|
-
return false;
|
|
34504
|
-
return variant.variantOptions.every((vOpt) => item.variantOptions.some((iOpt) => vOpt.name === iOpt.name && vOpt.value === iOpt.value));
|
|
34505
|
-
});
|
|
34506
|
-
const productItem = variant || item.product;
|
|
34492
|
+
const productItem = ((_a = item.product) === null || _a === void 0 ? void 0 : _a.selectedVariant) || item.product;
|
|
34507
34493
|
return (React__default.createElement("div", { key: index, className: "flex items-center" },
|
|
34508
34494
|
React__default.createElement("div", { className: "relative" },
|
|
34509
34495
|
React__default.createElement("div", { className: "w-16 h-16 bg-secondary rounded-lg overflow-hidden relative" }, (productItem === null || productItem === void 0 ? void 0 : productItem.images[0]) && (React__default.createElement("img", { src: productItem.images[0] ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betterstore/react",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "E-commerce for Developers",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"author": "Better Store",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@betterstore/sdk": "^0.3.
|
|
22
|
+
"@betterstore/sdk": "^0.3.41",
|
|
23
23
|
"@changesets/cli": "^2.28.1",
|
|
24
24
|
"@rollup/plugin-commonjs": "^28.0.3",
|
|
25
25
|
"@rollup/plugin-json": "^6.1.0",
|