@trafilea/afrodita-components 6.54.7 → 6.54.9

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/build/index.d.ts CHANGED
@@ -118,6 +118,7 @@ declare type Props$3 = PriceLabelProps & {
118
118
  savingsDisplay?: boolean;
119
119
  pricePerItem?: string;
120
120
  hasRoundedSavings?: boolean;
121
+ showDecimals?: boolean;
121
122
  };
122
123
  declare const PriceLabelV2: react__default.FC<Props$3>;
123
124
 
@@ -2810,6 +2811,7 @@ interface ProductItemSmallMobileProps extends ProductItemProps {
2810
2811
  isCollections?: boolean;
2811
2812
  };
2812
2813
  likeBtn?: LikeButtonProps;
2814
+ showDecimals?: boolean;
2813
2815
  }
2814
2816
 
2815
2817
  declare function withProductGrid<P extends ProductItemProps>(ProductItemComponent: react__default.FC<P>, data: ProductItemProps[]): {
@@ -3467,24 +3467,27 @@ var PriceLabel$1 = function (_a) {
3467
3467
  };
3468
3468
  var templateObject_1$2y, templateObject_2$1Q, templateObject_3$1q;
3469
3469
 
3470
+ var supportedCurrencies = ['AU$', 'CA$', '€', 'kr', '£', 'NZ$', 'S$'];
3471
+
3472
+ var getCurrencySymbol = function (finalPrice) {
3473
+ var currencySymbolFallback = '$';
3474
+ var currencySymbol = supportedCurrencies.find(function (symbol) { return finalPrice.startsWith(symbol); });
3475
+ return currencySymbol !== null && currencySymbol !== void 0 ? currencySymbol : currencySymbolFallback;
3476
+ };
3477
+
3470
3478
  var FinalPriceStyledContainer$3 = newStyled.div(templateObject_1$2x || (templateObject_1$2x = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
3471
3479
  var PriceLabelV2$1 = function (_a) {
3472
3480
  var _b;
3473
- var finalPrice = _a.finalPrice, originalPrice = _a.originalPrice, discount = _a.discount, clubOffer = _a.clubOffer, color = _a.color, testId = _a.testId, _c = _a.originalPriceStyled, originalPriceStyled = _c === void 0 ? false : _c, _d = _a.originalPriceUnderlined, originalPriceUnderlined = _d === void 0 ? true : _d, _e = _a.size, size = _e === void 0 ? ComponentSize.Small : _e, _f = _a.bordersRounded, bordersRounded = _f === void 0 ? false : _f, _g = _a.savingsDisplay, savingsDisplay = _g === void 0 ? true : _g, pricePerItem = _a.pricePerItem, _h = _a.hasRoundedSavings, hasRoundedSavings = _h === void 0 ? true : _h, rest = __rest(_a, ["finalPrice", "originalPrice", "discount", "clubOffer", "color", "testId", "originalPriceStyled", "originalPriceUnderlined", "size", "bordersRounded", "savingsDisplay", "pricePerItem", "hasRoundedSavings"]);
3481
+ var finalPrice = _a.finalPrice, originalPrice = _a.originalPrice, discount = _a.discount, clubOffer = _a.clubOffer, color = _a.color, testId = _a.testId, _c = _a.originalPriceStyled, originalPriceStyled = _c === void 0 ? false : _c, _d = _a.originalPriceUnderlined, originalPriceUnderlined = _d === void 0 ? true : _d, _e = _a.size, size = _e === void 0 ? ComponentSize.Small : _e, _f = _a.bordersRounded, bordersRounded = _f === void 0 ? false : _f, _g = _a.savingsDisplay, savingsDisplay = _g === void 0 ? true : _g, pricePerItem = _a.pricePerItem, _h = _a.hasRoundedSavings, hasRoundedSavings = _h === void 0 ? true : _h, _j = _a.showDecimals, showDecimals = _j === void 0 ? true : _j, rest = __rest(_a, ["finalPrice", "originalPrice", "discount", "clubOffer", "color", "testId", "originalPriceStyled", "originalPriceUnderlined", "size", "bordersRounded", "savingsDisplay", "pricePerItem", "hasRoundedSavings", "showDecimals"]);
3474
3482
  var theme = useTheme();
3475
3483
  var productFinalPrice = pricePerItem ? pricePerItem : finalPrice;
3476
3484
  var isDiffFinalAndOriginalPrice = originalPrice !== productFinalPrice;
3477
3485
  var isOriginalPrice = originalPrice && isDiffFinalAndOriginalPrice;
3478
3486
  var isDiscount = discount && isDiffFinalAndOriginalPrice;
3479
3487
  var isClubOffer = clubOffer && isDiffFinalAndOriginalPrice;
3480
- var supportedCurrencies = ['AU$', 'CA$', '£', 'NZ$', 'S$'];
3481
3488
  var currencySymbol = '$';
3482
3489
  if (typeof productFinalPrice === 'string') {
3483
- supportedCurrencies.forEach(function (availableCurrency) {
3484
- if (productFinalPrice.includes(availableCurrency)) {
3485
- currencySymbol = availableCurrency;
3486
- }
3487
- });
3490
+ currencySymbol = getCurrencySymbol(productFinalPrice);
3488
3491
  }
3489
3492
  var finalPriceArray = typeof productFinalPrice === 'string' &&
3490
3493
  productFinalPrice.includes('.') &&
@@ -3522,9 +3525,9 @@ var PriceLabelV2$1 = function (_a) {
3522
3525
  theme.colors.shades['300'].color, margin: true, underlined: originalPriceUnderlined, "data-testid": getTestId$2(testId, 'original-product-price') }, { children: originalPrice }), void 0)); };
3523
3526
  return (jsxs$1(Container$1w, __assign$1({}, rest, { id: "priceLabelV2" }, { children: [isOriginalPrice && jsx$1(OriginalPrice, {}, void 0), jsxs$1(FinalPriceStyledContainer$3, __assign$1({ "data-testid": getTestId$2(testId, 'final-product-price') }, { children: [jsx$1(Price$1, __assign$1({ margin: true, finalPriceStyledSmall: true }, priceCommonProps, { size: size }, { children: currencySymbol }), void 0), jsx$1(Price$1, __assign$1({ finalPriceStyled: true }, priceCommonProps, { size: size }, { children: finalPriceArray[0]
3524
3527
  ? finalPriceArray[0]
3525
- : (_b = "".concat(productFinalPrice)) === null || _b === void 0 ? void 0 : _b.split(currencySymbol)[1] }), void 0), jsx$1(Price$1, __assign$1({ finalPriceStyledSmall: true, style: {
3528
+ : (_b = "".concat(productFinalPrice)) === null || _b === void 0 ? void 0 : _b.split(currencySymbol)[1] }), void 0), showDecimals && (jsx$1(Price$1, __assign$1({ finalPriceStyledSmall: true, style: {
3526
3529
  marginTop: '-6px',
3527
- } }, priceCommonProps, { size: size }, { children: finalPriceArray[1] ? finalPriceArray[1] : '00' }), void 0), pricePerItem && (jsx$1(Price$1, __assign$1({ size: ComponentSize.Small, color: theme.colors.pallete.secondary.color }, { children: "/each" }), void 0))] }), void 0), isDiscount && (jsx$1(TagContainer, __assign$1({ size: ComponentSize.Small }, { children: discount && (jsx$1(DiscountTag$4, __assign$1({}, discount, { size: ComponentSize.Medium, style: {
3530
+ } }, priceCommonProps, { size: size }, { children: finalPriceArray[1] ? finalPriceArray[1] : '00' }), void 0)), pricePerItem && (jsx$1(Price$1, __assign$1({ size: ComponentSize.Small, color: theme.colors.pallete.secondary.color }, { children: "/each" }), void 0))] }), void 0), isDiscount && (jsx$1(TagContainer, __assign$1({ size: ComponentSize.Small }, { children: discount && (jsx$1(DiscountTag$4, __assign$1({}, discount, { size: ComponentSize.Medium, style: {
3528
3531
  letterSpacing: '-0.05rem',
3529
3532
  }, bordersRounded: bordersRounded, savings: savingsDisplay ? "Save ".concat(currencySymbol).concat(savetoString) : undefined }), void 0)) }), void 0)), isClubOffer && (jsx$1(TagContainer, __assign$1({ size: ComponentSize.Medium }, { children: clubOffer && (jsx$1(ClubOfferTag, __assign$1({}, clubOffer, { size: ComponentSize.Small, style: {
3530
3533
  borderRadius: '8px',
@@ -3549,14 +3552,9 @@ var PriceLabelV3 = function (_a) {
3549
3552
  var isOriginalPrice = originalPrice && isDiffFinalAndOriginalPrice;
3550
3553
  var isDiscount = discount && isDiffFinalAndOriginalPrice;
3551
3554
  var isClubOffer = clubOffer && isDiffFinalAndOriginalPrice;
3552
- var supportedCurrencies = ['AU$', 'CA$', '£', 'NZ$', 'S$'];
3553
3555
  var currencySymbol = '$';
3554
3556
  if (typeof finalPrice === 'string') {
3555
- supportedCurrencies.forEach(function (availableCurrency) {
3556
- if (finalPrice.includes(availableCurrency)) {
3557
- currencySymbol = availableCurrency;
3558
- }
3559
- });
3557
+ currencySymbol = getCurrencySymbol(finalPrice);
3560
3558
  }
3561
3559
  var finalPriceArray = typeof finalPrice === 'string' &&
3562
3560
  finalPrice.includes('.') &&
@@ -3658,14 +3656,9 @@ var PriceLabel = function (_a) {
3658
3656
  var theme = useTheme();
3659
3657
  var isDiffFinalAndOriginalPrice = originalPrice !== finalPrice;
3660
3658
  var isOriginalPrice = originalPrice && isDiffFinalAndOriginalPrice;
3661
- var supportedCurrencies = ['AU$', 'CA$', '£', 'NZ$', 'S$'];
3662
3659
  var currencySymbol = '$';
3663
3660
  if (typeof finalPrice === 'string') {
3664
- supportedCurrencies.forEach(function (availableCurrency) {
3665
- if (finalPrice.includes(availableCurrency)) {
3666
- currencySymbol = availableCurrency;
3667
- }
3668
- });
3661
+ currencySymbol = getCurrencySymbol(finalPrice);
3669
3662
  }
3670
3663
  var finalPriceArray = typeof finalPrice === 'string' &&
3671
3664
  finalPrice.includes('.') &&
@@ -3694,14 +3687,9 @@ var PriceLabelV2 = function (_a) {
3694
3687
  var theme = useTheme();
3695
3688
  var isDiffFinalAndOriginalPrice = originalPrice !== finalPrice;
3696
3689
  var isOriginalPrice = originalPrice && isDiffFinalAndOriginalPrice;
3697
- var supportedCurrencies = ['AU$', 'CA$', '£', 'NZ$', 'S$'];
3698
3690
  var currencySymbol = '$';
3699
3691
  if (typeof finalPrice === 'string') {
3700
- supportedCurrencies.forEach(function (availableCurrency) {
3701
- if (finalPrice.includes(availableCurrency)) {
3702
- currencySymbol = availableCurrency;
3703
- }
3704
- });
3692
+ currencySymbol = getCurrencySymbol(finalPrice);
3705
3693
  }
3706
3694
  var finalPriceArray = typeof finalPrice === 'string' &&
3707
3695
  finalPrice.includes('.') &&
@@ -7258,14 +7246,9 @@ var PriceLabelV4 = function (_a) {
7258
7246
  var theme = useTheme();
7259
7247
  var isMobile = useWindowDimensions().isMobile;
7260
7248
  var productFinalPrice = clubPrice;
7261
- var supportedCurrencies = ['AU$', 'CA$', '£', 'NZ$', 'S$'];
7262
7249
  var currencySymbol = '$';
7263
7250
  if (typeof productFinalPrice === 'string') {
7264
- supportedCurrencies.forEach(function (availableCurrency) {
7265
- if (productFinalPrice.includes(availableCurrency)) {
7266
- currencySymbol = availableCurrency;
7267
- }
7268
- });
7251
+ currencySymbol = getCurrencySymbol(productFinalPrice);
7269
7252
  }
7270
7253
  var finalPriceArray = typeof productFinalPrice === 'string' &&
7271
7254
  productFinalPrice.includes('.') &&
@@ -7448,7 +7431,7 @@ var ProductItemMobile = function (_a) {
7448
7431
  } : _s, _t = _a.hasStrength, hasStrength = _t === void 0 ? {
7449
7432
  strength: -1,
7450
7433
  description: '',
7451
- } : _t, _u = _a.clubPrice, clubPrice = _u === void 0 ? '' : _u, _v = _a.showClubPriceLabel, showClubPriceLabel = _v === void 0 ? false : _v, isRatingLoading = _a.isRatingLoading, _w = _a.version, version = _w === void 0 ? 1 : _w, _x = _a.showDiscountPercentageTag, showDiscountPercentageTag = _x === void 0 ? false : _x, discountTagLoading = _a.discountTagLoading, discountTag = _a.discountTag, _y = _a.isOnViewport, isOnViewport = _y === void 0 ? false : _y, _z = _a.hasDefaultSize, hasDefaultSize = _z === void 0 ? false : _z, clubOffer = _a.clubOffer, likeBtn = _a.likeBtn, onClickBottomButton = _a.onClickBottomButton;
7434
+ } : _t, _u = _a.clubPrice, clubPrice = _u === void 0 ? '' : _u, _v = _a.showClubPriceLabel, showClubPriceLabel = _v === void 0 ? false : _v, isRatingLoading = _a.isRatingLoading, _w = _a.version, version = _w === void 0 ? 1 : _w, _x = _a.showDiscountPercentageTag, showDiscountPercentageTag = _x === void 0 ? false : _x, discountTagLoading = _a.discountTagLoading, discountTag = _a.discountTag, _y = _a.isOnViewport, isOnViewport = _y === void 0 ? false : _y, _z = _a.hasDefaultSize, hasDefaultSize = _z === void 0 ? false : _z, clubOffer = _a.clubOffer, likeBtn = _a.likeBtn, onClickBottomButton = _a.onClickBottomButton, _0 = _a.showDecimals, showDecimals = _0 === void 0 ? true : _0;
7452
7435
  var theme = useTheme();
7453
7436
  var styles = getStylesBySize$b(size);
7454
7437
  var isMobile = useWindowDimensions().isMobile;
@@ -7493,7 +7476,7 @@ var ProductItemMobile = function (_a) {
7493
7476
  case 5:
7494
7477
  return (jsx(ClubOfferPriceLabelWrapper, __assign$1({ style: clubOffer === null || clubOffer === void 0 ? void 0 : clubOffer.wrapperStyle }, { children: jsx(ClubPriceMemberLabel, { isClub: true, isPDP: true, finalPrice: (_e = clubOffer === null || clubOffer === void 0 ? void 0 : clubOffer.price) === null || _e === void 0 ? void 0 : _e.finalPrice, originalPrice: (_f = clubOffer === null || clubOffer === void 0 ? void 0 : clubOffer.price) === null || _f === void 0 ? void 0 : _f.originalPrice, finalPriceStyled: false, color: price.color, size: ComponentSize.Medium, testId: "volume-discount-v4", clubStyle: showClubPriceLabel, icon: clubOffer === null || clubOffer === void 0 ? void 0 : clubOffer.clubOfferIcon, isCollections: clubOffer === null || clubOffer === void 0 ? void 0 : clubOffer.isCollections }, void 0) }), void 0));
7495
7478
  default:
7496
- return priceDisplayType === 'styled' ? (jsx(PriceLabelV2$1, { finalPrice: price.finalPrice, originalPrice: price.originalPrice, finalPriceStyled: false, color: price.color, size: ComponentSize.Large, testId: "volume-discount" }, void 0)) : (jsx(PriceLabel$1, { finalPrice: price.finalPrice, originalPrice: price.originalPrice, finalPriceStyled: false, color: price.color, size: ComponentSize.Medium, testId: "volume-discount", clubStyle: showClubPriceLabel, finalPriceStyle: showClubPriceLabel
7479
+ return priceDisplayType === 'styled' ? (jsx(PriceLabelV2$1, { finalPrice: price.finalPrice, originalPrice: price.originalPrice, finalPriceStyled: false, color: price.color, size: ComponentSize.Large, testId: "volume-discount", showDecimals: showDecimals }, void 0)) : (jsx(PriceLabel$1, { finalPrice: price.finalPrice, originalPrice: price.originalPrice, finalPriceStyled: false, color: price.color, size: ComponentSize.Medium, testId: "volume-discount", clubStyle: showClubPriceLabel, finalPriceStyle: showClubPriceLabel
7497
7480
  ? !isMobile
7498
7481
  ? { fontSize: '16px', fontWeight: 700 }
7499
7482
  : { fontSize: '12px', fontWeight: 700 }
@@ -7507,8 +7490,8 @@ var ProductItemMobile = function (_a) {
7507
7490
  return jsx(Fragment, {}, void 0);
7508
7491
  return (jsx(Rating, { size: size === ComponentSize.Large ? ComponentSize.Small : ComponentSize.XSmall, rating: rating.rating, reviews: rating.reviews, reviewsText: "", wrapWithParenthesis: true }, void 0));
7509
7492
  };
7510
- var _0 = useState((_b = likeBtn === null || likeBtn === void 0 ? void 0 : likeBtn.isLiked) !== null && _b !== void 0 ? _b : false), isLiked = _0[0], setIsLiked = _0[1];
7511
- var _1 = useState((_c = likeBtn === null || likeBtn === void 0 ? void 0 : likeBtn.likes) !== null && _c !== void 0 ? _c : 0), likesCount = _1[0], setLikesCount = _1[1];
7493
+ var _1 = useState((_b = likeBtn === null || likeBtn === void 0 ? void 0 : likeBtn.isLiked) !== null && _b !== void 0 ? _b : false), isLiked = _1[0], setIsLiked = _1[1];
7494
+ var _2 = useState((_c = likeBtn === null || likeBtn === void 0 ? void 0 : likeBtn.likes) !== null && _c !== void 0 ? _c : 0), likesCount = _2[0], setLikesCount = _2[1];
7512
7495
  var handleLikeClick = function (e) {
7513
7496
  e.stopPropagation();
7514
7497
  if (isLiked) {