@faststore/components 3.0.74 → 3.0.77
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/dist/cjs/molecules/OrderSummary/OrderSummary.d.ts +8 -0
- package/dist/cjs/molecules/OrderSummary/OrderSummary.js +4 -2
- package/dist/cjs/molecules/OrderSummary/OrderSummary.js.map +1 -1
- package/dist/cjs/molecules/ProductCard/ProductCardContent.d.ts +8 -0
- package/dist/cjs/molecules/ProductCard/ProductCardContent.js +2 -1
- package/dist/cjs/molecules/ProductCard/ProductCardContent.js.map +1 -1
- package/dist/cjs/molecules/SkuSelector/useSkuSlug.js +44 -1
- package/dist/cjs/molecules/SkuSelector/useSkuSlug.js.map +1 -1
- package/dist/esm/molecules/OrderSummary/OrderSummary.d.ts +8 -0
- package/dist/esm/molecules/OrderSummary/OrderSummary.js +5 -3
- package/dist/esm/molecules/OrderSummary/OrderSummary.js.map +1 -1
- package/dist/esm/molecules/ProductCard/ProductCardContent.d.ts +8 -0
- package/dist/esm/molecules/ProductCard/ProductCardContent.js +3 -2
- package/dist/esm/molecules/ProductCard/ProductCardContent.js.map +1 -1
- package/dist/esm/molecules/SkuSelector/useSkuSlug.js +44 -1
- package/dist/esm/molecules/SkuSelector/useSkuSlug.js.map +1 -1
- package/package.json +2 -2
- package/src/molecules/OrderSummary/OrderSummary.tsx +16 -1
- package/src/molecules/ProductCard/ProductCardContent.tsx +16 -0
- package/src/molecules/SkuSelector/useSkuSlug.ts +60 -5
|
@@ -30,6 +30,14 @@ export interface OrderSummaryProps extends HTMLAttributes<HTMLUListElement> {
|
|
|
30
30
|
* Total value of the order.
|
|
31
31
|
*/
|
|
32
32
|
totalValue?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Enables to include taxes status.
|
|
35
|
+
*/
|
|
36
|
+
includeTaxes?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Label to determine if the price is with taxes included.
|
|
39
|
+
*/
|
|
40
|
+
includeTaxesLabel?: string;
|
|
33
41
|
}
|
|
34
42
|
declare const OrderSummary: React.ForwardRefExoticComponent<OrderSummaryProps & React.RefAttributes<HTMLUListElement>>;
|
|
35
43
|
export default OrderSummary;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
const __1 = require("../../");
|
|
6
|
-
const OrderSummary = (0, react_1.forwardRef)(function OrderSummary({ testId = 'fs-order-summary', subtotalLabel, subtotalValue, discountLabel = 'Discount', discountValue, totalLabel = 'Total', totalValue, ...otherProps }, ref) {
|
|
6
|
+
const OrderSummary = (0, react_1.forwardRef)(function OrderSummary({ testId = 'fs-order-summary', subtotalLabel, subtotalValue, discountLabel = 'Discount', discountValue, totalLabel = 'Total', totalValue, includeTaxes = false, includeTaxesLabel = "Tax included", ...otherProps }, ref) {
|
|
7
7
|
return (react_1.default.createElement(__1.List, { ref: ref, "data-fs-order-summary": true, "data-testid": testId, ...otherProps },
|
|
8
8
|
subtotalValue ? (react_1.default.createElement("li", { "data-fs-order-summary-subtotal": true },
|
|
9
9
|
react_1.default.createElement("span", { "data-fs-order-summary-subtotal-label": true, "data-testid": `${testId}-subtotal-label` }, subtotalLabel),
|
|
@@ -13,7 +13,9 @@ const OrderSummary = (0, react_1.forwardRef)(function OrderSummary({ testId = 'f
|
|
|
13
13
|
react_1.default.createElement("span", { "data-fs-order-summary-discount-value": true, "data-testid": `${testId}-discount-value` }, discountValue))) : null,
|
|
14
14
|
react_1.default.createElement("li", { "data-fs-order-summary-total": true },
|
|
15
15
|
react_1.default.createElement("span", { "data-fs-order-summary-total-label": true, "data-testid": `${testId}-total-label` }, totalLabel),
|
|
16
|
-
react_1.default.createElement("span", { "data-fs-order-summary-total-value": true, "data-testid": `${testId}-total-value` }, totalValue))
|
|
16
|
+
react_1.default.createElement("span", { "data-fs-order-summary-total-value": true, "data-testid": `${testId}-total-value` }, totalValue)),
|
|
17
|
+
includeTaxes && (react_1.default.createElement("li", { "data-fs-order-summary-taxes-label": true },
|
|
18
|
+
react_1.default.createElement(__1.Label, null, includeTaxesLabel)))));
|
|
17
19
|
});
|
|
18
20
|
exports.default = OrderSummary;
|
|
19
21
|
//# sourceMappingURL=OrderSummary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderSummary.js","sourceRoot":"","sources":["../../../../src/molecules/OrderSummary/OrderSummary.tsx"],"names":[],"mappings":";;;AAAA,uDAAyC;AAGzC,
|
|
1
|
+
{"version":3,"file":"OrderSummary.js","sourceRoot":"","sources":["../../../../src/molecules/OrderSummary/OrderSummary.tsx"],"names":[],"mappings":";;;AAAA,uDAAyC;AAGzC,8BAAoC;AA0CpC,MAAM,YAAY,GAAG,IAAA,kBAAU,EAC7B,SAAS,YAAY,CACnB,EACE,MAAM,GAAG,kBAAkB,EAC3B,aAAa,EACb,aAAa,EACb,aAAa,GAAG,UAAU,EAC1B,aAAa,EACb,UAAU,GAAG,OAAO,EACpB,UAAU,EACV,YAAY,GAAG,KAAK,EACpB,iBAAiB,GAAG,cAAc,EAClC,GAAG,UAAU,EACd,EACD,GAAG;IAEH,OAAO,CACL,8BAAC,QAAI,IACH,GAAG,EAAE,GAAG,gDAEK,MAAM,KACf,UAAU;QAEb,aAAa,CAAC,CAAC,CAAC,CACf;YACE,qGAEe,GAAG,MAAM,iBAAiB,IAEtC,aAAa,CACT;YACP,qGAEe,GAAG,MAAM,iBAAiB,IAEtC,aAAa,CACT,CACJ,CACN,CAAC,CAAC,CAAC,IAAI;QACP,aAAa,CAAC,CAAC,CAAC,CACf;YACE,qGAEe,GAAG,MAAM,iBAAiB,IAEtC,aAAa,CACT;YACP,qGAEe,GAAG,MAAM,iBAAiB,IAEtC,aAAa,CACT,CACJ,CACN,CAAC,CAAC,CAAC,IAAI;QACR;YACE,kGAEe,GAAG,MAAM,cAAc,IAEnC,UAAU,CACN;YACP,kGAEe,GAAG,MAAM,cAAc,IAEnC,UAAU,CACN,CACJ;QACJ,YAAY,IAAI,CACf;YACE,8BAAC,SAAK,QAAE,iBAAiB,CAAS,CAC/B,CACJ,CACE,CACR,CAAA;AACH,CAAC,CACF,CAAA;AAED,kBAAe,YAAY,CAAA"}
|
|
@@ -43,6 +43,14 @@ export interface ProductCardContentProps extends HTMLAttributes<HTMLElement> {
|
|
|
43
43
|
* Callback function when button is clicked.
|
|
44
44
|
*/
|
|
45
45
|
onButtonClick?: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Enables to include taxes status.
|
|
48
|
+
*/
|
|
49
|
+
includeTaxes?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Label to determine if the price is with taxes included.
|
|
52
|
+
*/
|
|
53
|
+
includeTaxesLabel?: string;
|
|
46
54
|
}
|
|
47
55
|
declare const ProductCardContent: React.ForwardRefExoticComponent<ProductCardContentProps & React.RefAttributes<HTMLElement>>;
|
|
48
56
|
export default ProductCardContent;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
const __1 = require("../../");
|
|
6
|
-
const ProductCardContent = (0, react_1.forwardRef)(function CardContent({ testId = 'fs-product-card-content', title, linkProps, price, outOfStock, outOfStockLabel = 'Out of stock', ratingValue, showDiscountBadge, buttonLabel = 'Add', onButtonClick, children, ...otherProps }, ref) {
|
|
6
|
+
const ProductCardContent = (0, react_1.forwardRef)(function CardContent({ testId = 'fs-product-card-content', title, linkProps, price, outOfStock, outOfStockLabel = 'Out of stock', ratingValue, showDiscountBadge, buttonLabel = 'Add', onButtonClick, children, includeTaxes = false, includeTaxesLabel = "Tax included", ...otherProps }, ref) {
|
|
7
7
|
const listingPrice = price?.listPrice ? price.listPrice : 0;
|
|
8
8
|
const sellingPrice = price?.value ? price.value : 0;
|
|
9
9
|
return (react_1.default.createElement("section", { ref: ref, "data-fs-product-card-content": true, "data-fs-product-card-badge": showDiscountBadge, "data-testid": testId, ...otherProps },
|
|
@@ -12,6 +12,7 @@ const ProductCardContent = (0, react_1.forwardRef)(function CardContent({ testId
|
|
|
12
12
|
react_1.default.createElement(__1.Link, { ...linkProps, title: title },
|
|
13
13
|
react_1.default.createElement("span", null, title))),
|
|
14
14
|
!outOfStock && (react_1.default.createElement(__1.ProductPrice, { "data-fs-product-card-prices": true, value: sellingPrice, listPrice: listingPrice, formatter: price?.formatter })),
|
|
15
|
+
includeTaxes && (react_1.default.createElement(__1.Label, { "data-fs-product-card-taxes-label": true }, includeTaxesLabel)),
|
|
15
16
|
ratingValue && (react_1.default.createElement(__1.Rating, { value: ratingValue, icon: react_1.default.createElement(__1.Icon, { name: "Star" }) }))),
|
|
16
17
|
showDiscountBadge && !outOfStock && (react_1.default.createElement(__1.DiscountBadge, { listPrice: listingPrice, spotPrice: sellingPrice })),
|
|
17
18
|
outOfStock && react_1.default.createElement(__1.Badge, null, outOfStockLabel),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductCardContent.js","sourceRoot":"","sources":["../../../../src/molecules/ProductCard/ProductCardContent.tsx"],"names":[],"mappings":";;;AACA,uDAAyC;AAIzC,
|
|
1
|
+
{"version":3,"file":"ProductCardContent.js","sourceRoot":"","sources":["../../../../src/molecules/ProductCard/ProductCardContent.tsx"],"names":[],"mappings":";;;AACA,uDAAyC;AAIzC,8BAWe;AAqDf,MAAM,kBAAkB,GAAG,IAAA,kBAAU,EACnC,SAAS,WAAW,CAClB,EACE,MAAM,GAAG,yBAAyB,EAClC,KAAK,EACL,SAAS,EACT,KAAK,EACL,UAAU,EACV,eAAe,GAAG,cAAc,EAChC,WAAW,EACX,iBAAiB,EACjB,WAAW,GAAG,KAAK,EACnB,aAAa,EACb,QAAQ,EACR,YAAY,GAAG,KAAK,EACpB,iBAAiB,GAAG,cAAc,EAClC,GAAG,UAAU,EACd,EACD,GAAG;IAEH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 +8,52 @@ function getSkuSlug(slugsMap, selectedVariations, dominantVariation) {
|
|
|
8
8
|
return slugsMap[slugsMapKey];
|
|
9
9
|
}
|
|
10
10
|
const possibleVariants = Object.keys(slugsMap);
|
|
11
|
-
const
|
|
11
|
+
const dominantVariationKeyValue = `${dominantVariation}-${selectedVariations[dominantVariation]}`;
|
|
12
|
+
const slugVariationsForDominantValue = possibleVariants.filter((slug) => slug.includes(dominantVariationKeyValue));
|
|
13
|
+
const firstVariationForDominantValue = slugVariationsForDominantValue.length > 1
|
|
14
|
+
? getBestMatchVariation(slugVariationsForDominantValue, dominantVariationKeyValue)
|
|
15
|
+
: slugVariationsForDominantValue[0];
|
|
12
16
|
return slugsMap[firstVariationForDominantValue ?? possibleVariants[0]];
|
|
13
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* This function transforms a slug string into a record object.
|
|
20
|
+
* e.g. 'Color-Red-Size-40' => { Color: 'Red', Size: '40' }
|
|
21
|
+
* @param slug
|
|
22
|
+
* @returns the record object
|
|
23
|
+
*/
|
|
24
|
+
function transformSkuVariationsSlugToRecord(slug) {
|
|
25
|
+
const obj = {};
|
|
26
|
+
const parts = slug.split('-');
|
|
27
|
+
for (let i = 0; i < parts.length; i += 2) {
|
|
28
|
+
const key = parts[i].trim();
|
|
29
|
+
const value = parts[i + 1] ? parts[i + 1].trim() : '';
|
|
30
|
+
obj[key] = value;
|
|
31
|
+
}
|
|
32
|
+
return obj;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* This function receives a list of slug variations and a dominant variation key-value pair.
|
|
36
|
+
* It returns the exact match variation value for the dominant value.
|
|
37
|
+
* This happens when there are multiple variations filtered by the includes function (e.g. 7 is included in 7 and in 7.5).
|
|
38
|
+
*
|
|
39
|
+
*
|
|
40
|
+
* e.g. given the following params:
|
|
41
|
+
* slugVariationsForDominantValue = ['Color-Red-Size-7.5', 'Color-Blue-Size-7'],
|
|
42
|
+
* dominantVariationKeyValue = 'Size-7'.
|
|
43
|
+
*
|
|
44
|
+
* The function will return 'Color-Blue-Size-7'.
|
|
45
|
+
*
|
|
46
|
+
* @param slugVariationsForDominantValue
|
|
47
|
+
* @param dominantVariationKeyValue
|
|
48
|
+
* @returns the best match variation
|
|
49
|
+
*/
|
|
50
|
+
function getBestMatchVariation(slugVariationsForDominantValue, dominantVariationKeyValue) {
|
|
51
|
+
const [dominantKey, dominantValue] = dominantVariationKeyValue.split('-');
|
|
52
|
+
return slugVariationsForDominantValue.find((slug) => {
|
|
53
|
+
const slugRecord = transformSkuVariationsSlugToRecord(slug);
|
|
54
|
+
return slugRecord[dominantKey] === dominantValue;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
14
57
|
const useSkuSlug = (activeVariations, slugsMap, skuPropertyName, getItemHrefProp) => {
|
|
15
58
|
const getItemHref = (0, react_1.useCallback)((option) => {
|
|
16
59
|
if (getItemHrefProp)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSkuSlug.js","sourceRoot":"","sources":["../../../../src/molecules/SkuSelector/useSkuSlug.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AAGnC,SAAS,UAAU,CACjB,QAAgC,EAChC,kBAA0C,EAC1C,iBAAyB;IAEzB,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAEvE,IAAI,WAAW,IAAI,QAAQ,EAAE;QAC3B,OAAO,QAAQ,CAAC,WAAW,CAAC,CAAA;KAC7B;IAED,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAE9C,MAAM,8BAA8B,GAAG,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"useSkuSlug.js","sourceRoot":"","sources":["../../../../src/molecules/SkuSelector/useSkuSlug.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AAGnC,SAAS,UAAU,CACjB,QAAgC,EAChC,kBAA0C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I,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QACrD,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;KACjB;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAS,qBAAqB,CAC5B,8BAAwC,EACxC,yBAAiC;IAEjC,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,GAAG,yBAAyB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAEzE,OAAO,8BAA8B,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QAClD,MAAM,UAAU,GAAG,kCAAkC,CAAC,IAAI,CAAC,CAAA;QAE3D,OAAO,UAAU,CAAC,WAAW,CAAC,KAAK,aAAa,CAAA;IAClD,CAAC,CAAC,CAAA;AACJ,CAAC;AAEM,MAAM,UAAU,GAAG,CACxB,gBAAwC,EACxC,QAAgC,EAChC,eAAuB,EACvB,eAA+C,EAC/C,EAAE;IACF,MAAM,WAAW,GAAG,IAAA,mBAAW,EAC7B,CAAC,MAAiB,EAAE,EAAE;QACpB,IAAI,eAAe;YAAE,OAAO,EAAE,eAAe,EAAE,CAAA;QAE/C,MAAM,eAAe,GAAG,IAAI,UAAU,CACpC,QAAQ,EACR;YACE,GAAG,gBAAgB;YACnB,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,KAAK;SAChC,EACD,eAAe,CAChB,IAAI,CAAA;QACL,OAAO,eAAe,CAAA;IACxB,CAAC,EACD,CAAC,gBAAgB,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,CAAC,CAC/D,CAAA;IACD,OAAO,EAAE,WAAW,EAAE,CAAA;AACxB,CAAC,CAAA;AAvBY,QAAA,UAAU,cAuBtB"}
|
|
@@ -30,6 +30,14 @@ export interface OrderSummaryProps extends HTMLAttributes<HTMLUListElement> {
|
|
|
30
30
|
* Total value of the order.
|
|
31
31
|
*/
|
|
32
32
|
totalValue?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Enables to include taxes status.
|
|
35
|
+
*/
|
|
36
|
+
includeTaxes?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Label to determine if the price is with taxes included.
|
|
39
|
+
*/
|
|
40
|
+
includeTaxesLabel?: string;
|
|
33
41
|
}
|
|
34
42
|
declare const OrderSummary: React.ForwardRefExoticComponent<OrderSummaryProps & React.RefAttributes<HTMLUListElement>>;
|
|
35
43
|
export default OrderSummary;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
|
-
import { List } from '../../';
|
|
3
|
-
const OrderSummary = forwardRef(function OrderSummary({ testId = 'fs-order-summary', subtotalLabel, subtotalValue, discountLabel = 'Discount', discountValue, totalLabel = 'Total', totalValue, ...otherProps }, ref) {
|
|
2
|
+
import { Label, List } from '../../';
|
|
3
|
+
const OrderSummary = forwardRef(function OrderSummary({ testId = 'fs-order-summary', subtotalLabel, subtotalValue, discountLabel = 'Discount', discountValue, totalLabel = 'Total', totalValue, includeTaxes = false, includeTaxesLabel = "Tax included", ...otherProps }, ref) {
|
|
4
4
|
return (React.createElement(List, { ref: ref, "data-fs-order-summary": true, "data-testid": testId, ...otherProps },
|
|
5
5
|
subtotalValue ? (React.createElement("li", { "data-fs-order-summary-subtotal": true },
|
|
6
6
|
React.createElement("span", { "data-fs-order-summary-subtotal-label": true, "data-testid": `${testId}-subtotal-label` }, subtotalLabel),
|
|
@@ -10,7 +10,9 @@ const OrderSummary = forwardRef(function OrderSummary({ testId = 'fs-order-summa
|
|
|
10
10
|
React.createElement("span", { "data-fs-order-summary-discount-value": true, "data-testid": `${testId}-discount-value` }, discountValue))) : null,
|
|
11
11
|
React.createElement("li", { "data-fs-order-summary-total": true },
|
|
12
12
|
React.createElement("span", { "data-fs-order-summary-total-label": true, "data-testid": `${testId}-total-label` }, totalLabel),
|
|
13
|
-
React.createElement("span", { "data-fs-order-summary-total-value": true, "data-testid": `${testId}-total-value` }, totalValue))
|
|
13
|
+
React.createElement("span", { "data-fs-order-summary-total-value": true, "data-testid": `${testId}-total-value` }, totalValue)),
|
|
14
|
+
includeTaxes && (React.createElement("li", { "data-fs-order-summary-taxes-label": true },
|
|
15
|
+
React.createElement(Label, null, includeTaxesLabel)))));
|
|
14
16
|
});
|
|
15
17
|
export default OrderSummary;
|
|
16
18
|
//# sourceMappingURL=OrderSummary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderSummary.js","sourceRoot":"","sources":["../../../../src/molecules/OrderSummary/OrderSummary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGzC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"OrderSummary.js","sourceRoot":"","sources":["../../../../src/molecules/OrderSummary/OrderSummary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGzC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AA0CpC,MAAM,YAAY,GAAG,UAAU,CAC7B,SAAS,YAAY,CACnB,EACE,MAAM,GAAG,kBAAkB,EAC3B,aAAa,EACb,aAAa,EACb,aAAa,GAAG,UAAU,EAC1B,aAAa,EACb,UAAU,GAAG,OAAO,EACpB,UAAU,EACV,YAAY,GAAG,KAAK,EACpB,iBAAiB,GAAG,cAAc,EAClC,GAAG,UAAU,EACd,EACD,GAAG;IAEH,OAAO,CACL,oBAAC,IAAI,IACH,GAAG,EAAE,GAAG,gDAEK,MAAM,KACf,UAAU;QAEb,aAAa,CAAC,CAAC,CAAC,CACf;YACE,2FAEe,GAAG,MAAM,iBAAiB,IAEtC,aAAa,CACT;YACP,2FAEe,GAAG,MAAM,iBAAiB,IAEtC,aAAa,CACT,CACJ,CACN,CAAC,CAAC,CAAC,IAAI;QACP,aAAa,CAAC,CAAC,CAAC,CACf;YACE,2FAEe,GAAG,MAAM,iBAAiB,IAEtC,aAAa,CACT;YACP,2FAEe,GAAG,MAAM,iBAAiB,IAEtC,aAAa,CACT,CACJ,CACN,CAAC,CAAC,CAAC,IAAI;QACR;YACE,wFAEe,GAAG,MAAM,cAAc,IAEnC,UAAU,CACN;YACP,wFAEe,GAAG,MAAM,cAAc,IAEnC,UAAU,CACN,CACJ;QACJ,YAAY,IAAI,CACf;YACE,oBAAC,KAAK,QAAE,iBAAiB,CAAS,CAC/B,CACJ,CACE,CACR,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,YAAY,CAAA"}
|
|
@@ -43,6 +43,14 @@ export interface ProductCardContentProps extends HTMLAttributes<HTMLElement> {
|
|
|
43
43
|
* Callback function when button is clicked.
|
|
44
44
|
*/
|
|
45
45
|
onButtonClick?: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Enables to include taxes status.
|
|
48
|
+
*/
|
|
49
|
+
includeTaxes?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Label to determine if the price is with taxes included.
|
|
52
|
+
*/
|
|
53
|
+
includeTaxesLabel?: string;
|
|
46
54
|
}
|
|
47
55
|
declare const ProductCardContent: React.ForwardRefExoticComponent<ProductCardContentProps & React.RefAttributes<HTMLElement>>;
|
|
48
56
|
export default ProductCardContent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
|
-
import { Badge, Button, DiscountBadge, Icon, Link, ProductPrice, Rating, } from '../../';
|
|
3
|
-
const ProductCardContent = forwardRef(function CardContent({ testId = 'fs-product-card-content', title, linkProps, price, outOfStock, outOfStockLabel = 'Out of stock', ratingValue, showDiscountBadge, buttonLabel = 'Add', onButtonClick, children, ...otherProps }, ref) {
|
|
2
|
+
import { Badge, Button, DiscountBadge, Icon, Label, Link, ProductPrice, Rating, } from '../../';
|
|
3
|
+
const ProductCardContent = forwardRef(function CardContent({ testId = 'fs-product-card-content', title, linkProps, price, outOfStock, outOfStockLabel = 'Out of stock', ratingValue, showDiscountBadge, buttonLabel = 'Add', onButtonClick, children, includeTaxes = false, includeTaxesLabel = "Tax included", ...otherProps }, ref) {
|
|
4
4
|
const listingPrice = price?.listPrice ? price.listPrice : 0;
|
|
5
5
|
const sellingPrice = price?.value ? price.value : 0;
|
|
6
6
|
return (React.createElement("section", { ref: ref, "data-fs-product-card-content": true, "data-fs-product-card-badge": showDiscountBadge, "data-testid": testId, ...otherProps },
|
|
@@ -9,6 +9,7 @@ const ProductCardContent = forwardRef(function CardContent({ testId = 'fs-produc
|
|
|
9
9
|
React.createElement(Link, { ...linkProps, title: title },
|
|
10
10
|
React.createElement("span", null, title))),
|
|
11
11
|
!outOfStock && (React.createElement(ProductPrice, { "data-fs-product-card-prices": true, value: sellingPrice, listPrice: listingPrice, formatter: price?.formatter })),
|
|
12
|
+
includeTaxes && (React.createElement(Label, { "data-fs-product-card-taxes-label": true }, includeTaxesLabel)),
|
|
12
13
|
ratingValue && (React.createElement(Rating, { value: ratingValue, icon: React.createElement(Icon, { name: "Star" }) }))),
|
|
13
14
|
showDiscountBadge && !outOfStock && (React.createElement(DiscountBadge, { listPrice: listingPrice, spotPrice: sellingPrice })),
|
|
14
15
|
outOfStock && React.createElement(Badge, null, outOfStockLabel),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductCardContent.js","sourceRoot":"","sources":["../../../../src/molecules/ProductCard/ProductCardContent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAIzC,OAAO,EACL,KAAK,EACL,MAAM,EACN,aAAa,EACb,IAAI,EACJ,IAAI,EAGJ,YAAY,EACZ,MAAM,GACP,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"ProductCardContent.js","sourceRoot":"","sources":["../../../../src/molecules/ProductCard/ProductCardContent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA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aAAa,IAAC,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,GAAI,CACpE;QACA,UAAU,IAAI,oBAAC,KAAK,QAAE,eAAe,CAAS;QAC9C,aAAa,IAAI,CAAC,UAAU,IAAI,CAC/B;YACE,oBAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,IAAI,EAAE,oBAAC,IAAI,IAAC,IAAI,EAAC,cAAc,GAAG,EAClC,YAAY,EAAC,MAAM,EACnB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,aAAa,IAErB,WAAW,CACL,CACL,CACP,CACO,CACX,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,kBAAkB,CAAA"}
|
|
@@ -5,9 +5,52 @@ function getSkuSlug(slugsMap, selectedVariations, dominantVariation) {
|
|
|
5
5
|
return slugsMap[slugsMapKey];
|
|
6
6
|
}
|
|
7
7
|
const possibleVariants = Object.keys(slugsMap);
|
|
8
|
-
const
|
|
8
|
+
const dominantVariationKeyValue = `${dominantVariation}-${selectedVariations[dominantVariation]}`;
|
|
9
|
+
const slugVariationsForDominantValue = possibleVariants.filter((slug) => slug.includes(dominantVariationKeyValue));
|
|
10
|
+
const firstVariationForDominantValue = slugVariationsForDominantValue.length > 1
|
|
11
|
+
? getBestMatchVariation(slugVariationsForDominantValue, dominantVariationKeyValue)
|
|
12
|
+
: slugVariationsForDominantValue[0];
|
|
9
13
|
return slugsMap[firstVariationForDominantValue ?? possibleVariants[0]];
|
|
10
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* This function transforms a slug string into a record object.
|
|
17
|
+
* e.g. 'Color-Red-Size-40' => { Color: 'Red', Size: '40' }
|
|
18
|
+
* @param slug
|
|
19
|
+
* @returns the record object
|
|
20
|
+
*/
|
|
21
|
+
function transformSkuVariationsSlugToRecord(slug) {
|
|
22
|
+
const obj = {};
|
|
23
|
+
const parts = slug.split('-');
|
|
24
|
+
for (let i = 0; i < parts.length; i += 2) {
|
|
25
|
+
const key = parts[i].trim();
|
|
26
|
+
const value = parts[i + 1] ? parts[i + 1].trim() : '';
|
|
27
|
+
obj[key] = value;
|
|
28
|
+
}
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* This function receives a list of slug variations and a dominant variation key-value pair.
|
|
33
|
+
* It returns the exact match variation value for the dominant value.
|
|
34
|
+
* This happens when there are multiple variations filtered by the includes function (e.g. 7 is included in 7 and in 7.5).
|
|
35
|
+
*
|
|
36
|
+
*
|
|
37
|
+
* e.g. given the following params:
|
|
38
|
+
* slugVariationsForDominantValue = ['Color-Red-Size-7.5', 'Color-Blue-Size-7'],
|
|
39
|
+
* dominantVariationKeyValue = 'Size-7'.
|
|
40
|
+
*
|
|
41
|
+
* The function will return 'Color-Blue-Size-7'.
|
|
42
|
+
*
|
|
43
|
+
* @param slugVariationsForDominantValue
|
|
44
|
+
* @param dominantVariationKeyValue
|
|
45
|
+
* @returns the best match variation
|
|
46
|
+
*/
|
|
47
|
+
function getBestMatchVariation(slugVariationsForDominantValue, dominantVariationKeyValue) {
|
|
48
|
+
const [dominantKey, dominantValue] = dominantVariationKeyValue.split('-');
|
|
49
|
+
return slugVariationsForDominantValue.find((slug) => {
|
|
50
|
+
const slugRecord = transformSkuVariationsSlugToRecord(slug);
|
|
51
|
+
return slugRecord[dominantKey] === dominantValue;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
11
54
|
export const useSkuSlug = (activeVariations, slugsMap, skuPropertyName, getItemHrefProp) => {
|
|
12
55
|
const getItemHref = useCallback((option) => {
|
|
13
56
|
if (getItemHrefProp)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSkuSlug.js","sourceRoot":"","sources":["../../../../src/molecules/SkuSelector/useSkuSlug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAGnC,SAAS,UAAU,CACjB,QAAgC,EAChC,kBAA0C,EAC1C,iBAAyB;IAEzB,MAAM,WAAW,GA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,eAAe,GAAG,IAAI,UAAU,CACpC,QAAQ,EACR;YACE,GAAG,gBAAgB;YACnB,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,KAAK;SAChC,EACD,eAAe,CAChB,IAAI,CAAA;QACL,OAAO,eAAe,CAAA;IACxB,CAAC,EACD,CAAC,gBAAgB,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,CAAC,CAC/D,CAAA;IACD,OAAO,EAAE,WAAW,EAAE,CAAA;AACxB,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/components",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.77",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"typings": "dist/esm/index.d.ts",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"volta": {
|
|
50
50
|
"extends": "../../package.json"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "c03af091effe1a702a2cab6afe2e67fbb783d5dc"
|
|
53
53
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react'
|
|
2
2
|
import type { HTMLAttributes } from 'react'
|
|
3
3
|
|
|
4
|
-
import { List } from '../../'
|
|
4
|
+
import { Label, List } from '../../'
|
|
5
5
|
|
|
6
6
|
export interface OrderSummaryProps extends HTMLAttributes<HTMLUListElement> {
|
|
7
7
|
/**
|
|
@@ -33,6 +33,14 @@ export interface OrderSummaryProps extends HTMLAttributes<HTMLUListElement> {
|
|
|
33
33
|
* Total value of the order.
|
|
34
34
|
*/
|
|
35
35
|
totalValue?: string
|
|
36
|
+
/**
|
|
37
|
+
* Enables to include taxes status.
|
|
38
|
+
*/
|
|
39
|
+
includeTaxes?: boolean
|
|
40
|
+
/**
|
|
41
|
+
* Label to determine if the price is with taxes included.
|
|
42
|
+
*/
|
|
43
|
+
includeTaxesLabel?: string
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
const OrderSummary = forwardRef<HTMLUListElement, OrderSummaryProps>(
|
|
@@ -45,6 +53,8 @@ const OrderSummary = forwardRef<HTMLUListElement, OrderSummaryProps>(
|
|
|
45
53
|
discountValue,
|
|
46
54
|
totalLabel = 'Total',
|
|
47
55
|
totalValue,
|
|
56
|
+
includeTaxes = false,
|
|
57
|
+
includeTaxesLabel = "Tax included",
|
|
48
58
|
...otherProps
|
|
49
59
|
},
|
|
50
60
|
ref
|
|
@@ -102,6 +112,11 @@ const OrderSummary = forwardRef<HTMLUListElement, OrderSummaryProps>(
|
|
|
102
112
|
{totalValue}
|
|
103
113
|
</span>
|
|
104
114
|
</li>
|
|
115
|
+
{includeTaxes && (
|
|
116
|
+
<li data-fs-order-summary-taxes-label>
|
|
117
|
+
<Label>{includeTaxesLabel}</Label>
|
|
118
|
+
</li>
|
|
119
|
+
)}
|
|
105
120
|
</List>
|
|
106
121
|
)
|
|
107
122
|
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
Button,
|
|
9
9
|
DiscountBadge,
|
|
10
10
|
Icon,
|
|
11
|
+
Label,
|
|
11
12
|
Link,
|
|
12
13
|
LinkElementType,
|
|
13
14
|
LinkProps,
|
|
@@ -56,6 +57,14 @@ export interface ProductCardContentProps extends HTMLAttributes<HTMLElement> {
|
|
|
56
57
|
* Callback function when button is clicked.
|
|
57
58
|
*/
|
|
58
59
|
onButtonClick?: () => void
|
|
60
|
+
/**
|
|
61
|
+
* Enables to include taxes status.
|
|
62
|
+
*/
|
|
63
|
+
includeTaxes?: boolean
|
|
64
|
+
/**
|
|
65
|
+
* Label to determine if the price is with taxes included.
|
|
66
|
+
*/
|
|
67
|
+
includeTaxesLabel?: string
|
|
59
68
|
}
|
|
60
69
|
|
|
61
70
|
const ProductCardContent = forwardRef<HTMLElement, ProductCardContentProps>(
|
|
@@ -72,6 +81,8 @@ const ProductCardContent = forwardRef<HTMLElement, ProductCardContentProps>(
|
|
|
72
81
|
buttonLabel = 'Add',
|
|
73
82
|
onButtonClick,
|
|
74
83
|
children,
|
|
84
|
+
includeTaxes = false,
|
|
85
|
+
includeTaxesLabel = "Tax included",
|
|
75
86
|
...otherProps
|
|
76
87
|
},
|
|
77
88
|
ref
|
|
@@ -101,6 +112,11 @@ const ProductCardContent = forwardRef<HTMLElement, ProductCardContentProps>(
|
|
|
101
112
|
formatter={price?.formatter}
|
|
102
113
|
/>
|
|
103
114
|
)}
|
|
115
|
+
{includeTaxes && (
|
|
116
|
+
<Label data-fs-product-card-taxes-label>
|
|
117
|
+
{includeTaxesLabel}
|
|
118
|
+
</Label>
|
|
119
|
+
)}
|
|
104
120
|
{ratingValue && (
|
|
105
121
|
<Rating value={ratingValue} icon={<Icon name="Star" />} />
|
|
106
122
|
)}
|
|
@@ -14,15 +14,70 @@ function getSkuSlug(
|
|
|
14
14
|
|
|
15
15
|
const possibleVariants = Object.keys(slugsMap)
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
17
|
+
const dominantVariationKeyValue = `${dominantVariation}-${selectedVariations[dominantVariation]}`
|
|
18
|
+
|
|
19
|
+
const slugVariationsForDominantValue = possibleVariants.filter((slug) =>
|
|
20
|
+
slug.includes(dominantVariationKeyValue)
|
|
21
21
|
)
|
|
22
22
|
|
|
23
|
+
const firstVariationForDominantValue =
|
|
24
|
+
slugVariationsForDominantValue.length > 1
|
|
25
|
+
? getBestMatchVariation(
|
|
26
|
+
slugVariationsForDominantValue,
|
|
27
|
+
dominantVariationKeyValue
|
|
28
|
+
)
|
|
29
|
+
: slugVariationsForDominantValue[0]
|
|
30
|
+
|
|
23
31
|
return slugsMap[firstVariationForDominantValue ?? possibleVariants[0]]
|
|
24
32
|
}
|
|
25
33
|
|
|
34
|
+
/**
|
|
35
|
+
* This function transforms a slug string into a record object.
|
|
36
|
+
* e.g. 'Color-Red-Size-40' => { Color: 'Red', Size: '40' }
|
|
37
|
+
* @param slug
|
|
38
|
+
* @returns the record object
|
|
39
|
+
*/
|
|
40
|
+
function transformSkuVariationsSlugToRecord(slug: string) {
|
|
41
|
+
const obj = {} as Record<string, string>
|
|
42
|
+
const parts = slug.split('-')
|
|
43
|
+
|
|
44
|
+
for (let i = 0; i < parts.length; i += 2) {
|
|
45
|
+
const key = parts[i].trim()
|
|
46
|
+
const value = parts[i + 1] ? parts[i + 1].trim() : ''
|
|
47
|
+
obj[key] = value
|
|
48
|
+
}
|
|
49
|
+
return obj
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* This function receives a list of slug variations and a dominant variation key-value pair.
|
|
54
|
+
* It returns the exact match variation value for the dominant value.
|
|
55
|
+
* This happens when there are multiple variations filtered by the includes function (e.g. 7 is included in 7 and in 7.5).
|
|
56
|
+
*
|
|
57
|
+
*
|
|
58
|
+
* e.g. given the following params:
|
|
59
|
+
* slugVariationsForDominantValue = ['Color-Red-Size-7.5', 'Color-Blue-Size-7'],
|
|
60
|
+
* dominantVariationKeyValue = 'Size-7'.
|
|
61
|
+
*
|
|
62
|
+
* The function will return 'Color-Blue-Size-7'.
|
|
63
|
+
*
|
|
64
|
+
* @param slugVariationsForDominantValue
|
|
65
|
+
* @param dominantVariationKeyValue
|
|
66
|
+
* @returns the best match variation
|
|
67
|
+
*/
|
|
68
|
+
function getBestMatchVariation(
|
|
69
|
+
slugVariationsForDominantValue: string[],
|
|
70
|
+
dominantVariationKeyValue: string
|
|
71
|
+
) {
|
|
72
|
+
const [dominantKey, dominantValue] = dominantVariationKeyValue.split('-')
|
|
73
|
+
|
|
74
|
+
return slugVariationsForDominantValue.find((slug) => {
|
|
75
|
+
const slugRecord = transformSkuVariationsSlugToRecord(slug)
|
|
76
|
+
|
|
77
|
+
return slugRecord[dominantKey] === dominantValue
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
26
81
|
export const useSkuSlug = (
|
|
27
82
|
activeVariations: Record<string, string>,
|
|
28
83
|
slugsMap: Record<string, string>,
|
|
@@ -31,7 +86,7 @@ export const useSkuSlug = (
|
|
|
31
86
|
) => {
|
|
32
87
|
const getItemHref = useCallback(
|
|
33
88
|
(option: SkuOption) => {
|
|
34
|
-
if(getItemHrefProp) return { getItemHrefProp }
|
|
89
|
+
if (getItemHrefProp) return { getItemHrefProp }
|
|
35
90
|
|
|
36
91
|
const currentItemHref = `/${getSkuSlug(
|
|
37
92
|
slugsMap,
|