@trafilea/afrodita-components 6.5.3 → 6.5.4

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.js CHANGED
@@ -5480,31 +5480,26 @@ var templateObject_1$1A, templateObject_2$10, templateObject_3$Q;
5480
5480
  var FinalPriceStyledContainer$1 = newStyled.div(templateObject_1$1z || (templateObject_1$1z = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
5481
5481
  var PriceLabelV2 = function (_a) {
5482
5482
  var _b;
5483
- 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 ? exports.ComponentSize.Small : _e, _f = _a.bordersRounded, bordersRounded = _f === void 0 ? false : _f, _g = _a.savingsDisplay, savingsDisplay = _g === void 0 ? true : _g, hasPricePerItem = _a.hasPricePerItem, _h = _a.quantity, quantity = _h === void 0 ? 0 : _h, rest = __rest(_a, ["finalPrice", "originalPrice", "discount", "clubOffer", "color", "testId", "originalPriceStyled", "originalPriceUnderlined", "size", "bordersRounded", "savingsDisplay", "hasPricePerItem", "quantity"]);
5483
+ 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 ? exports.ComponentSize.Small : _e, _f = _a.bordersRounded, bordersRounded = _f === void 0 ? false : _f, _g = _a.savingsDisplay, savingsDisplay = _g === void 0 ? true : _g, pricePerItem = _a.pricePerItem, rest = __rest(_a, ["finalPrice", "originalPrice", "discount", "clubOffer", "color", "testId", "originalPriceStyled", "originalPriceUnderlined", "size", "bordersRounded", "savingsDisplay", "pricePerItem"]);
5484
5484
  var theme = useTheme();
5485
- var isDiffFinalAndOriginalPrice = originalPrice !== finalPrice;
5485
+ var productFinalPrice = pricePerItem ? pricePerItem : finalPrice;
5486
+ var isDiffFinalAndOriginalPrice = originalPrice !== productFinalPrice;
5486
5487
  var isOriginalPrice = originalPrice && isDiffFinalAndOriginalPrice;
5487
5488
  var isDiscount = discount && isDiffFinalAndOriginalPrice;
5488
5489
  var isClubOffer = clubOffer && isDiffFinalAndOriginalPrice;
5489
5490
  var supportedCurrencies = ['A$', 'CA$', '£'];
5490
5491
  var currencySymbol = '$';
5491
- if (typeof finalPrice === 'string') {
5492
+ if (typeof productFinalPrice === 'string') {
5492
5493
  supportedCurrencies.forEach(function (availableCurrency) {
5493
- if (finalPrice.includes(availableCurrency)) {
5494
+ if (productFinalPrice.includes(availableCurrency)) {
5494
5495
  currencySymbol = availableCurrency;
5495
5496
  }
5496
5497
  });
5497
5498
  }
5498
- var priceSymbolRemoved = typeof finalPrice === 'string' && finalPrice.includes(currencySymbol)
5499
- ? finalPrice.split(currencySymbol)[1]
5500
- : finalPrice;
5501
- var finalPricePerQuantity = hasPricePerItem
5502
- ? "".concat(currencySymbol).concat((Number(priceSymbolRemoved) / quantity).toFixed(2))
5503
- : finalPrice;
5504
- var finalPriceArray = typeof finalPricePerQuantity === 'string' &&
5505
- finalPricePerQuantity.includes('.') &&
5506
- finalPricePerQuantity.includes(currencySymbol)
5507
- ? finalPricePerQuantity.split(currencySymbol)[1].split('.')
5499
+ var finalPriceArray = typeof productFinalPrice === 'string' &&
5500
+ productFinalPrice.includes('.') &&
5501
+ productFinalPrice.includes(currencySymbol)
5502
+ ? productFinalPrice.split(currencySymbol)[1].split('.')
5508
5503
  : ['', ''];
5509
5504
  var priceCommonProps = {
5510
5505
  size: exports.ComponentSize.Small,
@@ -5514,13 +5509,13 @@ var PriceLabelV2 = function (_a) {
5514
5509
  weight: 700,
5515
5510
  };
5516
5511
  var originalPriceNum, finalPriceNum;
5517
- if (typeof originalPrice === 'string' && typeof finalPrice === 'string') {
5512
+ if (typeof originalPrice === 'string' && typeof productFinalPrice === 'string') {
5518
5513
  originalPriceNum = Number(originalPrice.replace(currencySymbol, ''));
5519
- finalPriceNum = Number(finalPrice.replace(currencySymbol, ''));
5514
+ finalPriceNum = Number(productFinalPrice.replace(currencySymbol, ''));
5520
5515
  }
5521
5516
  else {
5522
5517
  originalPriceNum = typeof originalPrice === 'number' ? originalPrice : 0;
5523
- finalPriceNum = typeof finalPrice === 'number' ? finalPrice : 0;
5518
+ finalPriceNum = typeof productFinalPrice === 'number' ? productFinalPrice : 0;
5524
5519
  }
5525
5520
  var saveto = originalPriceNum - finalPriceNum;
5526
5521
  var decimalPart = Number((saveto - Math.floor(saveto)).toFixed(2));
@@ -5535,9 +5530,11 @@ var PriceLabelV2 = function (_a) {
5535
5530
  theme.colors.shades['300'].color, margin: true, underlined: originalPriceUnderlined, "data-testid": getTestId(testId, 'original-product-price') }, { children: originalPrice }), void 0)); };
5536
5531
  return (jsxRuntime.jsxs(Container$Z, __assign$1({}, rest, { children: [isOriginalPrice && jsxRuntime.jsx(OriginalPrice, {}, void 0), jsxRuntime.jsxs(FinalPriceStyledContainer$1, __assign$1({ "data-testid": getTestId(testId, 'final-product-price') }, { children: [jsxRuntime.jsx(Price, __assign$1({ margin: true, finalPriceStyledSmall: true, style: {
5537
5532
  marginTop: '-5px',
5538
- } }, priceCommonProps, { size: size }, { children: currencySymbol }), void 0), jsxRuntime.jsx(Price, __assign$1({ finalPriceStyled: true }, priceCommonProps, { size: size }, { children: finalPriceArray[0] ? finalPriceArray[0] : (_b = "".concat(finalPrice)) === null || _b === void 0 ? void 0 : _b.split(currencySymbol)[1] }), void 0), jsxRuntime.jsx(Price, __assign$1({ finalPriceStyledSmall: true, style: {
5533
+ } }, priceCommonProps, { size: size }, { children: currencySymbol }), void 0), jsxRuntime.jsx(Price, __assign$1({ finalPriceStyled: true }, priceCommonProps, { size: size }, { children: finalPriceArray[0]
5534
+ ? finalPriceArray[0]
5535
+ : (_b = "".concat(productFinalPrice)) === null || _b === void 0 ? void 0 : _b.split(currencySymbol)[1] }), void 0), jsxRuntime.jsx(Price, __assign$1({ finalPriceStyledSmall: true, style: {
5539
5536
  marginTop: '-6px',
5540
- } }, priceCommonProps, { size: size }, { children: finalPriceArray[1] ? finalPriceArray[1] : '00' }), void 0), hasPricePerItem && (jsxRuntime.jsx(Price, __assign$1({ size: exports.ComponentSize.Small, color: theme.colors.pallete.secondary.color }, { children: "/each" }), void 0))] }), void 0), isDiscount && (jsxRuntime.jsx(TagContainer, __assign$1({ size: exports.ComponentSize.Small }, { children: discount && (jsxRuntime.jsx(DiscountTag, __assign$1({}, discount, { size: exports.ComponentSize.Medium, style: {
5537
+ } }, priceCommonProps, { size: size }, { children: finalPriceArray[1] ? finalPriceArray[1] : '00' }), void 0), pricePerItem && (jsxRuntime.jsx(Price, __assign$1({ size: exports.ComponentSize.Small, color: theme.colors.pallete.secondary.color }, { children: "/each" }), void 0))] }), void 0), isDiscount && (jsxRuntime.jsx(TagContainer, __assign$1({ size: exports.ComponentSize.Small }, { children: discount && (jsxRuntime.jsx(DiscountTag, __assign$1({}, discount, { size: exports.ComponentSize.Medium, style: {
5541
5538
  letterSpacing: '-0.05rem',
5542
5539
  }, bordersRounded: bordersRounded, savings: savingsDisplay ? "Save ".concat(currencySymbol).concat(savetoString) : undefined }), void 0)) }), void 0)), isClubOffer && (jsxRuntime.jsx(TagContainer, __assign$1({ size: exports.ComponentSize.Medium }, { children: clubOffer && (jsxRuntime.jsx(ClubOfferTag, __assign$1({}, clubOffer, { size: exports.ComponentSize.Small, style: {
5543
5540
  borderRadius: '8px',
@@ -5556,7 +5553,7 @@ var ContainerDirectionColumn = newStyled.div(templateObject_2$$ || (templateObje
5556
5553
  var DiscountEachOneContainer = newStyled.div(templateObject_3$P || (templateObject_3$P = __makeTemplateObject(["\n display: flex;\n padding-left: 0.5rem;\n"], ["\n display: flex;\n padding-left: 0.5rem;\n"])));
5557
5554
  var PriceLabelV3 = function (_a) {
5558
5555
  var _b;
5559
- 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 ? exports.ComponentSize.Small : _e, _f = _a.bordersRounded, bordersRounded = _f === void 0 ? false : _f, _g = _a.savingsDisplay, savingsDisplay = _g === void 0 ? true : _g, itemsQuantity = _a.itemsQuantity, rest = __rest(_a, ["finalPrice", "originalPrice", "discount", "clubOffer", "color", "testId", "originalPriceStyled", "originalPriceUnderlined", "size", "bordersRounded", "savingsDisplay", "itemsQuantity"]);
5556
+ 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 ? exports.ComponentSize.Small : _e, _f = _a.bordersRounded, bordersRounded = _f === void 0 ? false : _f, _g = _a.savingsDisplay, savingsDisplay = _g === void 0 ? true : _g, itemsQuantity = _a.itemsQuantity, packUnitPrice = _a.packUnitPrice, rest = __rest(_a, ["finalPrice", "originalPrice", "discount", "clubOffer", "color", "testId", "originalPriceStyled", "originalPriceUnderlined", "size", "bordersRounded", "savingsDisplay", "itemsQuantity", "packUnitPrice"]);
5560
5557
  var theme = useTheme();
5561
5558
  var isDiffFinalAndOriginalPrice = originalPrice !== finalPrice;
5562
5559
  var isOriginalPrice = originalPrice && isDiffFinalAndOriginalPrice;
@@ -5604,17 +5601,15 @@ var PriceLabelV3 = function (_a) {
5604
5601
  var OriginalPrice = function () { return (jsxRuntime.jsx(Price, __assign$1({ size: originalPriceStyled ? size : exports.ComponentSize.Small, color: theme.component.pricing.priceLabel.price.originalPriceColor ||
5605
5602
  theme.colors.shades['300'].color, margin: true, underlined: originalPriceUnderlined, "data-testid": getTestId(testId, 'original-product-price') }, { children: originalPrice }), void 0)); };
5606
5603
  var DiscountedPriceOfEach = function () {
5607
- var priceEachOne;
5608
5604
  if (!itemsQuantity || itemsQuantity < 2)
5609
5605
  return null;
5610
- priceEachOne = (finalPriceNum / itemsQuantity).toFixed(2);
5611
- return (jsxRuntime.jsxs(DiscountEachOneContainer, __assign$1({ "data-testid": getTestId(testId, 'each-one-price') }, { children: [jsxRuntime.jsxs(Price, __assign$1({}, priceCommonProps, { weight: 600 }, { children: ["(", currencySymbol, priceEachOne] }), void 0), jsxRuntime.jsx(Price, __assign$1({}, priceCommonProps, { weight: 400 }, { children: "/each" }), void 0), jsxRuntime.jsx(Price, __assign$1({}, priceCommonProps, { weight: 600 }, { children: ")" }), void 0)] }), void 0));
5606
+ return (jsxRuntime.jsxs(DiscountEachOneContainer, __assign$1({ "data-testid": getTestId(testId, 'each-one-price') }, { children: [jsxRuntime.jsxs(Price, __assign$1({}, priceCommonProps, { weight: 600 }, { children: ["(", packUnitPrice] }), void 0), jsxRuntime.jsx(Price, __assign$1({}, priceCommonProps, { weight: 400 }, { children: "/each" }), void 0), jsxRuntime.jsx(Price, __assign$1({}, priceCommonProps, { weight: 600 }, { children: ")" }), void 0)] }), void 0));
5612
5607
  };
5613
5608
  return (jsxRuntime.jsxs(ContainerDirectionColumn, __assign$1({}, rest, { children: [jsxRuntime.jsx(Container$Z, __assign$1({ style: { paddingBottom: '0.5rem' } }, { children: isOriginalPrice && jsxRuntime.jsx(OriginalPrice, {}, void 0) }), void 0), jsxRuntime.jsxs(Container$Z, { children: [jsxRuntime.jsxs(FinalPriceStyledContainer, __assign$1({ "data-testid": getTestId(testId, 'final-product-price') }, { children: [jsxRuntime.jsx(Price, __assign$1({ margin: true, finalPriceStyledSmall: true, style: {
5614
5609
  marginTop: '-5px',
5615
5610
  } }, priceCommonProps, { size: size }, { children: currencySymbol }), void 0), jsxRuntime.jsx(Price, __assign$1({ finalPriceStyled: true }, priceCommonProps, { size: size }, { children: finalPriceArray[0] ? finalPriceArray[0] : (_b = "".concat(finalPrice)) === null || _b === void 0 ? void 0 : _b.split(currencySymbol)[1] }), void 0), jsxRuntime.jsx(Price, __assign$1({ finalPriceStyledSmall: true, style: {
5616
5611
  marginTop: '-6px',
5617
- } }, priceCommonProps, { size: size }, { children: finalPriceArray[1] ? finalPriceArray[1] : '00' }), void 0)] }), void 0), itemsQuantity ? jsxRuntime.jsx(DiscountedPriceOfEach, {}, void 0) : null, isDiscount && (jsxRuntime.jsx(TagContainer, __assign$1({ size: exports.ComponentSize.Small }, { children: discount && (jsxRuntime.jsx(DiscountTag, __assign$1({}, discount, { size: exports.ComponentSize.Medium, style: {
5612
+ } }, priceCommonProps, { size: size }, { children: finalPriceArray[1] ? finalPriceArray[1] : '00' }), void 0)] }), void 0), jsxRuntime.jsx(DiscountedPriceOfEach, {}, void 0), isDiscount && (jsxRuntime.jsx(TagContainer, __assign$1({ size: exports.ComponentSize.Small }, { children: discount && (jsxRuntime.jsx(DiscountTag, __assign$1({}, discount, { size: exports.ComponentSize.Medium, style: {
5618
5613
  letterSpacing: '-0.05rem',
5619
5614
  }, bordersRounded: bordersRounded, savings: savingsDisplay ? "SAVE ".concat(currencySymbol).concat(savetoString) : undefined, showSavings: true }), void 0)) }), void 0)), isClubOffer && (jsxRuntime.jsx(TagContainer, __assign$1({ size: exports.ComponentSize.Medium }, { children: clubOffer && (jsxRuntime.jsx(ClubOfferTag, __assign$1({}, clubOffer, { size: exports.ComponentSize.Small, style: {
5620
5615
  borderRadius: '8px',